if cmp /etc/hosts /etc/hosts then echo "Compare the same file..." echo Obviously you get true fi
cd /tmp echo "line 1 line 2 line 4" > tmp1$$ echo "line 2 line 3" > tmp2$$ diff tmp1$$ tmp2$$ rm tmp1$$ tmp2$$
find . -name "*" -print find / -name core -exec rm {} \;
head -50 file
# some of these options may be # invalid for your Unix version ps -aex | more
kill PID
sleep 20
grep pattern fileIt prints each line in the file that matches the pattern. You won't believe how useful this is till you have a lot of files...
cat /etc/services echo "------------------------------- Now grepping for word \"time\" -------------------------------" grep time /etc/servicesWith multiple files, you also get the filename as well as the line matched: The -l option just tells you which files contain matching lines
echo "hello..."
sed 1,10d fileprints file with lines 1-10 deleted
sed 20q fileprints first 20 lines and then quits
sed -n 20,30p file-n turns off default printing, so only prints lines 20 to 30
sed 's/old/new/' fileprints file with occurrences of ``old'' changed to ``new''.
If no file is given, sed reads from standard input e.g. to remove the first header line from ps output
ps | sed 1d
test -f file test -r file [ -f file ] test 20 -lt 3
if test -d /bin then echo "/bin is a directory" fi
expr 20 + 3