Bash Tricks

Some bash tricks, just to remember them,,,

Read from file

Read the file using cat:

cat file.txt | while read line 
do 
    echo "${line}" 
done

Or read a list of files using find:

find -iname "*.mp3" | while read line 
do 
    echo "${line}" 
done



Backup with tar over ssh

$ tar xzvf - /home/user/dir | ssh user@server "dd of="/dest/dir/file.tar.gz



Get one script's current directory

scriptdir=$(cd $(dirname $0); pwd -P)


 
linux/bash_tricks.txt · Last modified: 2008/10/31 19:05 by infinito

www.infinicode.org Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki