Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use xargs of sehll

Shulou Source: shulou.com Published: 2022-06-01 14:22:12 09月28日 Update

In this article, the editor introduces in detail "how to use sehll's xargs". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to use sehll's xargs" can help you solve your doubts.

Introduction to xargs

Xargs is a filter that passes parameters to a command

It is also a tool for combining multiple commands (some commands cannot be piped, we use xargs to solve this problem)

Xargs can convert pipe or standard input (stdin) data into command line arguments, 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 supplement to multi-line.

The input to xargs will contain line breaks and whitespace, but with xargs processing, line feeds and whitespace will be replaced by spaces

Xargs is a powerful command that captures the output of one command and passes it to another command.

Xargs usage example

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, this article "how to use xargs in sehll" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it before you can understand it. If you want to know more about related articles, please follow the industry information channel.

Tags: Command file user article multiline input content parameter beginning ownership data directory blank pipe processing output proper powerful backup multiple Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi vpn Redmi Huawei