$ ls -l produces output formatted similar to (Net web server)
$ ls -l produces output formatted similar to the following: total 64 -rw-r–r– 1 ranga users 635 Nov 29 11:10 awkfruit.sh -rw-r–r– 1 ranga users 115 Nov 28 14:07 fruit_prices.txt -rw-r–r– 1 ranga users 80 Nov 27 13:53 fruit_prices.txt.7880 lrwxrwxrwx 1 ranga users 8 Nov 27 19:01 nash -> nash.txt -rw-r–r– 1 ranga users 62 Nov 27 16:06 nash.txt -rw-r–r– 1 ranga users 11 Nov 29 10:38 nums.txt lrwxrwxrwx 1 ranga users 8 Nov 27 19:01 urls -> urls.txt -rw-r–r– 1 ranga users 180 Nov 27 12:34 urls.txt You can use awk to manipulate the output of the ls -l command so that only the name of a file and its size are printed. Here, the name of the file is in field 9, and the size is in field 5. The following command prints the name of each file along with its size: $ /bin/ls -l | awk ‘$1 !~ /total/ { printf “%-32s %sn”,$9,$5 ; }’ The output looks like the following: awkfruit.sh 635 fruit_prices.txt 115 fruit_prices.txt.7880 80 nash 8 nash.txt 62 nums.txt 11 urls 8 urls.txt 180 Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 17: Filtering Text with awk Previous Chapter Next Chapter Sections in this Chapter: What is awk? Questions Using awk Features Terms Summary Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.