Title my be ambiguous. Here’s an example of what I’m asking.
#ls -l
prints me out something like this
-rw-r--r-- 1 root root 5110 2011-10-08 19:36 test.txt
-rw-r--r-- 1 root root 5111 2011-10-08 19:38 test.txt
-rw-r--r-- 1 root root 5121 2011-10-08 19:36 5110.txt
-rw-r--r-- 1 root root 5122 2011-10-08 19:38 5111.txt
Say I wanted to use grep to find all filenames containing '511' and print out the size/filename of the file.
How do I grep for filenames '511', still print the filesize, and not have the output contain the top two rows.
thank you very much SO, reading man pages hasn’t helped me on this one.
You can use
awkfor this:It simply checks field 8 (the filename) to see if it starts with “511” and, if so, prints out fields 5 and 8, the size and name.