Skip to main content
2 of 4
edited tags
trolkura
  • 417
  • 1
  • 6
  • 15

Using xargs for more commands

Is it possible to use find + xargs in order to invoke more than one command? I am trying to find all files whose size is greater than 100 chars. and less than 1000 chars , change their permissions and print list of files into file. I can do it with exec e.g

find . -maxdepth 1 -size +100c -size -1000c -exec chmod a+r {} \; -print > testfile 

But is there any way how to achieve this with xargs?

 find . -maxdepth 1 -size +100c -size -1000c -print0 | xargs -0 -I '{}' chmod a+r '{}' -print >testfile 

the last print wont execute or throws error , is there a way how to achieve it with xargs?

trolkura
  • 417
  • 1
  • 6
  • 15