Quantcast
Channel: Awk for certain files in a directory - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 3

Awk for certain files in a directory

$
0
0

I have a directory called 'directory1' with files: file1, file2, file3, that have been passed by in a variable 'files'. Echo $files has the following output: file1 file2 file3. I want to have the sum of the sizes but the code below only works for only one file. How can I make it work for all the files?

ls -l ./$dir/$files | awk '{t+=$5}END{print t}'


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images