How to download the content from a URL?

wget -t 45 -o log &

(make 45 attempts and write log to log)

Now if you want to download a list of files from some location than

wget -t 45 -o log*.bz2 &

will not work so you need to do:

wget -o log -r -l1 --no-parent -A.bz2 &

to download all your files to your local drive.


How to extract bz2 file?

bunzip2 file-name.bz2

How to extract tgz file?

It depends on the tar file. ".tgz" "_tar.gz" means it is tarred and gzipped.

in that case:

tar -zxvf file_tar.gz

If it is just ".tar" "_tar" it isn't zipped, so take the z off.

"tar -xvf file_tar"

tar and gziP:

tar czvf myfile.tgz myfile


"gtar xzvf file.tar.gz" or "gunzip -c file.tar.gz |tar xvf -"

How to extract zip file?

unzip -d thedir

How to protect file from being deleted?

chmod a-w filename

How to do For loops in bash?

for file in *.txt; do echo $file; done

will print all files with extension .txt to console

Links that I found useful:

Tomcat wouldn't start but throws Connection refused...exception?


ps axf | grep [j]ava.endorsed.dir


ps ax | grep [j]ava.endorsed.dir

on Mac)

this will show the PID which you then need to kill:

kill -9 PID

read details here

Get processes which are running

ps auxgwwww | less

Find out which program is running on a port

sudo lsof -i :80

List all users on a linux server

Cat /etc/passwd |grep "/home" |cut -d: -f1

How to open TextEdit from Command Line?

open -a TextEdit nameOfTheFile.txt

How to download multiple files from a URL using a wildcard?

An example downloading FIBO ontologies:

wget -r -l3 --no-parent -A.rdf

Read more here.

How to switch between different versions of Java on Mac OS X?

1) Install all of them e.g. 1.6, 1.7, and 1.8.

2) Add to your ~/.bash_profile

export JAVA_HOME=$(/usr/libexec/java_home -v 1.7) setjdk() {   export JAVA_HOME=$(/usr/libexec/java_home -v $1) } 

Now you can:

$ java -version java version "1.7.0_51" Java(TM) SE Runtime Environment (build 1.7.0_51-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode) $ setjdk 1.6 $ java -version java version "1.6.0_65" Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode) $ setjdk 1.8 $ java -version java version "1.8.0" Java(TM) SE Runtime Environment (build 1.8.0-b132) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode) 

How to write output of a system.err.println to a file in bash?

To write the output of the System.err.println to the file do the following:

> outputfilename.log 2>&1

Which process is running on a port?

For example, to find out what's running on port 9000, run this command:

$ lsof -i :9000

List existing conda environements

conda info --envs

SBT/Scala Exception: Failed to construct terminal; falling back to unsupported java.lang.NumberFormatException: For input string: "0x100"

After updating my iOS recently to Mohave 10.14 I encountered this exception and solved it following the advice from this link
1. Check the value for your $TERM variable:
echo $TERM


2. Update it:

export TERM=xterm-color

3. Carry on, it works!

Full exception:

[ERROR] Failed to construct terminal; falling back to unsupported

java.lang.NumberFormatException: For input string: "0x100"

at java.lang.NumberFormatException.forInputString(

at java.lang.Integer.parseInt(

at java.lang.Integer.valueOf(

at jline.internal.InfoCmp.parseInfoCmp(

at jline.UnixTerminal.parseInfoCmp(

at jline.UnixTerminal.<init>(

at jline.UnixTerminal.<init>(

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(

at java.lang.reflect.Constructor.newInstance(

at java.lang.Class.newInstance(

at jline.TerminalFactory.getFlavor(

at jline.TerminalFactory.create(

at jline.TerminalFactory.get(

at jline.TerminalFactory.get(

at jline.console.ConsoleReader.<init>(

at jline.console.ConsoleReader.<init>(

at jline.console.ConsoleReader.<init>(

at sbt.JLine$$anonfun$createReader$1.apply(LineReader.scala:103)

at sbt.JLine$$anonfun$createReader$1.apply(LineReader.scala:102)

at sbt.JLine$$anonfun$usingTerminal$1.apply(LineReader.scala:98)

at sbt.JLine$$anonfun$usingTerminal$1.apply(LineReader.scala:96)

at sbt.JLine$.withTerminal(LineReader.scala:89)

at sbt.JLine$.usingTerminal(LineReader.scala:96)

at sbt.JLine$.createReader(LineReader.scala:102)

at sbt.SimpleReader.<init>(LineReader.scala:139)

at sbt.SimpleReader$.<init>(LineReader.scala:141)

at sbt.SimpleReader$.<clinit>(LineReader.scala)

at sbtrelease.ReleaseStateTransformations$.readVersion(ReleaseExtra.scala:274)

at sbtrelease.ReleaseStateTransformations$$anonfun$inquireVersions$1.apply(ReleaseExtra.scala:67)

at sbtrelease.ReleaseStateTransformations$$anonfun$inquireVersions$1.apply(ReleaseExtra.scala:56)

at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$4.sbtrelease$ReleasePlugin$autoImport$ReleaseKeys$$anonfun$$filterFailure$1(ReleasePlugin.scala:150)

at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$4$$anonfun$7$$anonfun$apply$3.apply(ReleasePlugin.scala:164)

at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$4$$anonfun$7$$anonfun$apply$3.apply(ReleasePlugin.scala:164)

at scala.Function$$anonfun$chain$1$$anonfun$apply$1.apply(Function.scala:24)

at scala.Function$$anonfun$chain$1$$anonfun$apply$1.apply(Function.scala:24)

at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111)

at scala.collection.immutable.List.foldLeft(List.scala:84)

at scala.collection.TraversableOnce$class.$div$colon(TraversableOnce.scala:138)

at scala.collection.AbstractTraversable.$div$colon(Traversable.scala:105)

at scala.Function$$anonfun$chain$1.apply(Function.scala:24)

at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$4.apply(ReleasePlugin.scala:168)

at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$4.apply(ReleasePlugin.scala:132)

at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)

at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)

at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)

at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)

at sbt.Command$.process(Command.scala:93)

at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)

at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)

at sbt.State$$anon$1.doX$1(State.scala:183)

at sbt.State$$anon$1.process(State.scala:190)

at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)

at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)

at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)

at sbt.MainLoop$.next(MainLoop.scala:96)

at sbt.MainLoop$.run(MainLoop.scala:89)

at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:68)

at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:63)

at sbt.Using.apply(Using.scala:24)

at sbt.MainLoop$.runWithNewLog(MainLoop.scala:63)

at sbt.MainLoop$.runAndClearLast(MainLoop.scala:46)

at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:30)

at sbt.MainLoop$.runLogged(MainLoop.scala:22)

at sbt.StandardMain$.runManaged(Main.scala:109)


at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)

at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)

at xsbt.boot.Launch$.run(Launch.scala:109)

at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)

at xsbt.boot.Launch$.launch(Launch.scala:117)

at xsbt.boot.Launch$.apply(Launch.scala:18)

at xsbt.boot.Boot$.runImpl(Boot.scala:41)

at xsbt.boot.Boot$.main(Boot.scala:17)

at xsbt.boot.Boot.main(Boot.scala)

How to convert Mac new line into unix new line?

This will replace mac new lines with unix new lines:

 tr '\r' '\n' < myfile-with-mac-new-line.tsv > new-file-with-unix-new-line.tsv 

How to search and replace using sed in vim editor?

This will replace old_string with new_string: