Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Cloud Computing Learning Route course syllabus material: parameter passing Xargs

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Today, I would like to share with you some course outline materials on cloud computing learning routes. This article is about some learning notes on parameter passing Xargs. I hope I can give you some help:

=

Awk sed grep sort uniq less more xargs

Xargs: ls cp rm

Case 1

[root@localhost ~] # touch / home/file {1.. 5}

[root@localhost ~] # vim files.txt

/ home/file1

/ home/file2

/ home/file3

/ home/file4

/ home/file5

[root@localhost ~] # cat files.txt | ls-l

[root@localhost ~] # cat files.txt | rm-rvf

Cont.

[root@localhost ~] # cat files.txt | xargs ls-l

-rw-r--r--. 1 root root 0 Mar 11 10:35 / home/file1

-rw-r--r--. 1 root root 0 Mar 11 10:35 / home/file2

-rw-r--r--. 1 root root 0 Mar 11 10:35 / home/file4

-rw-r--r--. 1 root root 0 Mar 11 10:35 / home/file5

[root@localhost ~] # cat files.txt | xargs rm-rvf

Removed'/ home/file1'

Removed'/ home/file2'

Removed'/ home/file4'

Removed'/ home/file5'

Case 2

[root@localhost ~] # touch / home/file {1.. 5}

[root@localhost ~] # cat files.txt | xargs-I {} ls-l {}

-rw-r--r--. 1 root root 0 Mar 11 10:40 / home/file1

-rw-r--r--. 1 root root 0 Mar 11 10:40 / home/file2

-rw-r--r--. 1 root root 0 Mar 11 10:40 / home/file4

-rw-r--r--. 1 root root 0 Mar 11 10:40 / home/file5

[root@localhost ~] # cat files.txt | xargs-I {} cp-rvf {} / tmp

'/ home/file1'->' / tmp/file1'

'/ home/file2'->' / tmp/file2'

'/ home/file4'->' / tmp/file4'

'/ home/file5'->' / tmp/file5'

[root@localhost ~] # cat files.txt | xargs-I YANG cp-rvf YANG / var/tmp

'/ home/file1'->' / var/tmp/file1'

'/ home/file2'->' / var/tmp/file2'

'/ home/file4'->' / var/tmp/file4'

'/ home/file5'->' / var/tmp/file5'

Case 3

[root@localhost ~] # find / etc-iname "* ifcfg*" | xargs-I {} cp-rf {} / tmp

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report