3

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

3

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.