In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Xiaobian to share with you the use of linux xargs command filter, I believe most people still do not know how to share this article for everyone to learn, I hope you read this article after the harvest, let us learn the method together!
The xargs command is a filter for passing arguments to other commands and a tool for combining multiple commands. It is good at converting standard input data into command line arguments, xargs can handle pipes or stdin and convert them into command arguments for specific commands.
Xargs can also convert single or multiline text input to other formats, such as multiline to single line or single-line to multiline. The default command for xargs is echo, and spaces are the default delimiter. This means that input piped to xargs will contain newlines and whitespace, but with xargs processing newlines and whitespace will be replaced by whitespace. Xargs is one of the important components of building a one-line command.
Syntax format: xargs [parameter]
Common parameters:
-n multiline output-d customize a delimiter-I specify a replacement string {}-t print out the commands xargs executes-p pop up confirmation when executing each command
Reference Example
Multiline output:
[root@linuxcool ~]#cat test.txt | xargs -n3
Customize a delimiter:
[root@linuxcool ~]#echo "nameXnameXnameXname" | xargs -dXname name name name
Specify a replacement string {}:
[root@linuxcool ~]#cat arg.txt | xargs -I {} ./ sk.sh -p {} -l-p aaa -l-p bbb -l-p ccc -l
Print out the commands xargs executes:
[root@linuxcool ~]#ls | xargs -t -I{} echo {}
A confirmation pops up for each command, when you need to confirm each action very accurately:
[root@linuxcool ~]#find . -maxdepth 1 -name "*.log" |xargs -p -I{} rm {} This is all about using linux xargs command filters. Thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to 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: 0
*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.