I would like to see the file list which contains the data.
Ex : - When I enter the "ls -ltr" command it will show all the files which are exists in the directory, But I want only those files list which are non zero byte by using only ls command.
I knew that I can write a script with "-s" option through script but I want the list through ls command...
For better understanding I am posting with example : -
$ls -ltr
-rw-r--r-- 1 userID MyGroup 0 Mar 2 10:27 a.txt
-rw-r--r-- 1 userID MyGroup 0 Mar 2 10:27 b.txt
-rw-r--r-- 1 userID MyGroup 50 Mar 2 10:27 c.txt
-rw-r--r-- 1 userID MyGroup 0 Mar 2 10:27 d.txt
-rw-r--r-- 1 userID MyGroup 200 Mar 2 11:24 e.txt
-rw-r--r-- 1 userID MyGroup 0 Mar 4 03:14 f.txt
-rw-r--r-- 1 userID MyGroup 100 Mar 4 03:14 g.txt
-rw-r--r-- 1 userID MyGroup 0 Mar 4 03:14 h.txt
-rw-r--r-- 1 userID MyGroup 0 Mar 4 03:14 i.txt
I want to see only c.txt, e.txt and g.txt from the above list, not all.
Please advice me how to solve this.
---------- Post updated at 05:17 AM ---------- Previous update was at 05:15 AM ----------
I don't want to delete the 0 byte files, I want to list out only those files which caontains data.
The awk processor implicitly reads lines and breaks them apart into fields that are numbered $1, $2, etc. One can then check the content of these fields in a number of ways, one being arithmetically.
So the above code means print each line where field 5 is not zero. Many awk scripts are complex, but many are simple, and often are easily constructed when dealing with operations that are naturally numeric. Regular expressions may still be used, but that's a different story.
There are controls that can change the settings for what characters separate the fields, etc., but the defaults are usually acceptable for many cases.
For the data posted, this produced:
-rw-r--r-- 1 userID MyGroup 50 Mar 2 10:27 c.txt
-rw-r--r-- 1 userID MyGroup 200 Mar 2 11:24 e.txt
-rw-r--r-- 1 userID MyGroup 100 Mar 4 03:14 g.txt
Best wishes ... cheers, drl
(The columns in the above output do not line up because the data was not originally posted within CODE tags.)