sort

sorting by other than first column

use the -k option:

ls -ltr | sort -k 10

sorts by the data in column 10

sed

escaping slash (/) character in sed

simply use

sed -e 's|fsdkfsd/fsdfsd/fdsfs|blablaa|g'

instead of

sed -e 's/fsdkfsd\/fsdfsd\/fdsfs/blablaa/g'

grep

searching for A or B

use egrep:

egrep "A|B" <whatever

read

working on single columns of an ascii file (zsh):

cat myfile.csv | while read -A columns; do echo column[0]==$column[0]; done

for bash:

cat myfile.csv | while read -a columns; do echo column[0]==${column[0]}; done

SHELLtips (last edited 2009-09-30 12:04:34 by AlexKaplan)