In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use the xargs command in the linux system, the article is very detailed, has a certain reference value, interested friends must read it!
Xargs is a filter for passing parameters to commands and a tool for combining multiple commands. Xargs can convert pipe or standard input (stdin) data into command line parameters or read data from the output of a file. Xargs can also convert single-line or multi-line text input to other formats, such as multi-line to single-line, single-line to multi-line.
Command format: somecommand | xargs-item command parameter:-a file is read from the file as stdin-e flag, note that sometimes it may be-E stdin-e flag flag must be a space-separated flag, when the xargs analysis contains the flag flag will stop. -p ask the user once when one argument is executed at a time. -n num is followed by a number of times to indicate the number of argument used at a time when the command is executed. By default, all are used. -t means to print the command before executing it. -I or-I, depending on the support of linux, assign each name of xargs, usually line by line, to {}, which can be replaced by {}. -r no-run-if-empty stops xargs when the input to xargs is empty, and you don't have to execute it anymore. The maximum number of characters on the-s num command line, which refers to the maximum number of command line characters for the command that follows xargs. -L num reads num lines once from standard input and sends them to the command command. -l is the same as-L. The-d delim delimiter. The default xargs delimiter is carriage return, and the argument delimiter is a space. Here, the xargs delimiter is modified. The meaning of-x exit is mainly used with-s. -P modify the maximum number of processes. The default is 1 and 0 is as many as it can. I didn't expect this example. It should not be used at ordinary times. An example of xargs application
1. Find the file and change the user to which the file belongs
# will change the file user starting with test in the current directory to zhangy [root@BlackGhost download] # find. -name "test*"-print | xargs chown zhangy:users# to view the file that begins with test in the current directory belongs to the user [root@BlackGhost download] # find. -name "test*"-print-exec ls-al {}\;. / test.sql.zip-rw-r--r-- 1 zhangy users 1981 Feb 2 16:05. / test.sql.zip./test.zip-rw-r--r-- 1 zhangy users 16 May 23 22:54. / test.zip
2. Count the users of the system.
[zhangy@BlackGhost download] # cut-d:-F1 > / home/zhangy/userlist.txt
3. Back up files
[zhangy@BlackGhost ddd] $ls | xargs-I cp {} {}. Bakcp test test.bak above is all the content of this article "how to use xargs commands in linux system". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 210
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.