xargs Command
ls |xargs -n 3
2) How can we ask for prompt from xargs command before execution ?
ls |xargs -p -n 3
3) How can we remove all html files older than 30 days by help of xargs ?
find / -name "*.html" -type f -mtime +30 |xargs rm -f
4) How can we remove all files those have white-space " " in it's name and extension is csv ?
find / -name "*.csv" -print0 | xargs -0 rm -f
Note:- "print0" option search files those have whitespace in it's name with regular file name as well.
5) How can we find all txt files those have "string" word in it's content ?
find / -name "*.txt" -type f |xargs grep string
6) Find all mp3 files and copy all to directory by xargs
find / -name "*.mp3" -type f |xargs cp {} /path/
7) Find all mp3 files and archived those
find / -name "*.mp3" -type f |xargs tar -cvfz songs.tar.gz
No comments:
Post a Comment