Misc skills


export command search path

export javadir=/data/workspace/java/
export PATH=$PATH:/home/yezheng/personal/
export PATH=$PATH:/data/workspace/java/lucene2.4/bin/
export PATH=$PATH:/data/soft/google/google_appengine/
export PATH=$PATH:/data/soft/wine/winelocale-read-only/current


Prompt Display

To let bash return "user@hostname:path/to/directory$" as your prompt, add the following line to your ~/.bash_profile:
 export PS1='\u@\H:\w$' 
to make the changes take effect immediately, run the following command in every open window (or restart Terminal):
 source ~/.bash_profile 
Inside PS1 value, "\w" represents the full path, where "\W" represents the current directory name only.


Display Disk Speed Info

 sudo hdparm -tT /dev/hda 


Bash Rename File Extensions

Below is a simple example for renaming uppercase jpg files to lowercase:
for i in *.JPG; do mv $i ${i%%.JPG}.jpg; done
If you would like to use this function for other types of files here is a basic template:
for i in *.; do mv $i ${i%%.}.; done
Another example
for i in *.JPG; do j=`echo $i | cut -d . -f 1`; j=$j"_from_mark.jpg"; echo $j; mv $i $j; done;


Display Ubuntu version

lsb_release -a
OR
cat /proc/version


APT install

  • dropbox
sudo add-apt-repository ppa:hertzog/nautilus-dropbox
sudo apt-get update
sudo apt-get install nautilus-dropbox
  • java
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-plugin

sudo update-alternatives --config java


evince: Chinese support

just install xpdf

Count the number files in a tar

tar -tf trec_data1.tar | wc -l

Task: List the contents of a tar file

Use the following command:
$ tar -tvf file.tar

Task: List the contents of a tar.gz file

Use the following command:
$ tar -ztvf file.tar.gz

Task: List the contents of a tar.bz2 file

Use the following command:
$ tar -jtvf file.tar.bz2
Where,
  • t: List the contents of an archive
  • v: Verbosely list files processed (display detailed information)
  • z: Filter the archive through gzip so that we can open compressed (decompress) .gz tar file
  • j: Filter archive through bzip2, use to decompress .bz2 files.
  • f filename: Use archive file called filename


Extract images from a PDF document

 pdfimages -j foo.pdf  bar 

Popular Posts