ls -la | grep ‘pattern’ | awk ‘{ print $9 }’ | xargs -I% truncate -s 0 %

explanation:

  • awk is used to print out the file name

  • xargs with pipe (|) will pick the file name from the previous step then call the truncate function, -I in xargs is substitution (can use: any character, for eg: % or {} or $, …)