The awk command combines the functions of grep and sed, making it one of
the most powerful unix commands. Using awk, you can substitute words
from an input file's lines for words in a template or perform
calculations on numbers within a file. (In case you're wondering how awk
got such an offbeat name, it's derived from the surnames of the three
programmers who invented it.)
[oracle@usha scripts]$ ls -l *.sql -rw-r--r--. 1 oracle oinstall 23 Feb 5 14:04 a.sql -rw-r--r--. 1 oracle oinstall 25 Feb 4 17:16 test.sql [oracle@usha scripts]$ ls -l *.sql|awk '{print $1}' -rw-r--r--. -rw-r--r--. [oracle@usha scripts]$ ls -l *.sql|awk '{print $2}' 1 1 [oracle@usha scripts]$ ls -l *.sql|awk '{print $8}' 14:04 17:16 [oracle@usha scripts]$ ls -l *.sql|awk '{print $9}' a.sql test.sql [oracle@usha scripts]$ ls -l *.sql|awk '{print $9}'>allsql [oracle@usha scripts]$ cat allsql a.sql test.sql [oracle@usha scripts]$ [oracle@usha scripts]$ cat allsql|sed 's/^/@/' @a.sql @test.sql [oracle@usha scripts]$ cat allsql|sed 's/^/@/'|sed 's/[\t]*$/;/' @a.sql; @test.sql; [oracle@usha scripts]$ ls -l *.sql|awk '{print "rm",$9}' rm a.sql rm test.sql [oracle@usha scripts]$ |