I want to list all files that has the text VIPCustomer="true" in it. I also want to just show file names that has NewCustomer in it. I do this with this:

grep -lr --include='*' 'VIPCustomer="true"' | grep NewCustomer

But how can I also include the file size of the files that are being listed?

1 Answer 1


Run du or ls -s on the filenames. You can use xargs to convert the output from grep to arguments for du or ls. Example:

grep -Zlr --include='*NewCustomer*' 'VIPCustomer="true"' | xargs -0 du --
grep -Zlr --include='*NewCustomer*' 'VIPCustomer="true"' | xargs -0 ls -s --

The -Z/-0 options use ASCII nul-terminated input/output, so all valid filenames are safely handled.

  • xargs -0 ls -l at the end worked ! Thanks for the help!
    – Solo
    Jan 15, 2018 at 8:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .