云计算学习路线课程大纲资料:参数传递 Xargs

今天给大家分享一些云计算学习路线课程大纲资料,这篇文章是关于参数传递 Xargs的一些学习笔记资料,希望能给大家一些帮助:

1566355636330512.jpeg

====================================================================================

awk sed grep sort uniq less more xargs

xargs: ls cp rm

案例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’

案例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’

案例3

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


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/69916964/viewspace-2654385/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/69916964/viewspace-2654385/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值