Linux Command play xargs we can use pipelines to redirect the standard output of one command to the standard output of another command, but some commands
Xargs is used to receive data only in the form of command line parameters, but not through stdin. Xargs should follow the pipeline operator. 1. Convert multiple rows to a single row and convert a single row to multiple rows. [Root @ localhost desktop] # cat show.txt wangHunan Chenzhou123456 zookeeper [root @ localhost desktop] # cat show.txt | xargswang Hunan Chenzhou 123456 li Guangzhou Zhuhai 654321 [root @ localhost desktop] # | xargs-n 4 wang Hunan Chenzhou 123456li Guangzhou Zhuhai 654321 2. -d option [root @ localhost desktop] # cat show.txt | xargs-d "\ n" wang Hunan Chenzhou 123456 li Guangzhou Zhuhai 654321 3. read stdi N. Pass the formatting parameters to the Command (one or more) [root @ localhost desktop] # vi ceshi. sh #! /Bin/bashecho $ * 'OK' [root @ localhost desktop] # chmod + x ceshi. sh [root @ localhost desktop] # cat show.txt | xargs-n 1. /ceshi. sh wangOKHunanOKChenzhouOK123456OKliOKGuangzhouOKZhuhaiOK654321OK [root @ localhost desktop] # cat show.txt | xargs. /ceshi. sh wang Hunan Cheng Zhou 123456 li Guangzhou Zhuhai 654321OK 4. pass complex command parameters (variable or immutable parameters)-I option to replace the character [root @ localhost desktop] # cat show.txt | xargs-I {}. /ceshi. sh-p {}-1-p wang-1OK-p Hu Nan Chenzhou-1OK-p 123456-1OK-p li-1OK-p Guangzhou Zhuhai-1OK-p 654321-1OK 5. use xargs with other commands [root @ localhost desktop] # file * | grep show | cut-d ": "-f1 | xargs wc-l8 show.txt [root @ localhost desktop] $ file * | grep show | cut-d ": "-f1 | xargs-t wc-lwc-l show.txt 8 show.txt-t option, print the command first, then run [root @ localhost desktop] # file * | grep show | cut-d ": "-f1 | xargs vi open the vi editor [root @ localhost desktop] # file * | grep s How | cut-d ":"-f1 | xargs-t-I mv {}{}. bakmv show.txt. modify the bak name [root @ localhost desktop] $ find. -name "*. txt "-type f-print0 | xargs-0 tar-zcvf text.tar.gz search for all txt files and compress them. In fact, xargs can be connected to many commands and you will find them very interesting.