Hello,
I have the output of ls -l stored in a text file called "files.txt".
-rwx------ 1 user1 dev 130 Sep 21 16:14 sc1.sh
-rwxr----- 1 user1 dev 10328 Sep 29 20:11 sc10.sh
-rwxr----- 1 user1 dev 9984 Sep 30 15:33 sc11.sh
-rwxr----- 1 user1 dev 9987 Oct 1 10:05 sc12.sh
-rwx------ 1 user1 dev 3215 Sep 21 17:15 sc2.sh
-rwx------ 1 user1 dev 3215 Sep 22 10:04 sc3.sh
-rwxr----- 1 user1 dev 2174 Sep 22 13:34 sc4.sh
-rwxr----- 1 user1 dev 2837 Sep 22 16:35 sc5.sh
-rwxr----- 1 user1 dev 5923 Sep 23 11:51 sc6.sh
-rwxr----- 1 user1 dev 5995 Sep 23 13:20 sc7.sh
-rwxr----- 1 user1 dev 6458 Sep 24 13:37 sc8.sh
-rwxr----- 1 user1 dev 8375 Sep 26 10:53 sc9.sh
I need to extract the filename and filesize, viz column 9 & 5 for all files matching a filename pattern into another file.
I have tried the following shell script.
set -f
FILE_EXT=*.sh
awk '{print $9" "$5}' files.txt | grep "$FILE_EXT"
It does not print the rows with the patterns. The pattern used for grep through the shell script needs to be configurable via the command line.
Can anybody help me with this.
Thanks.