Chinaunix首页 | 论坛 | 博客
  • 博客访问: 308170
  • 博文数量: 43
  • 博客积分: 1590
  • 博客等级: 上尉
  • 技术积分: 508
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-22 22:16
个人简介

温柔的IT民工~

文章分类

全部博文(43)

文章存档

2013年(1)

2012年(2)

2011年(2)

2010年(7)

2009年(8)

2008年(15)

2007年(8)

分类: 系统运维

2013-09-26 18:09:41

 xargs的使用:
# find / -type f -name "*.log" -print|xargs  ls  -l #会在执行命令后过段时间才会有输出,即:find完成后结果一块echo给ls 作为输入,只执行了一次ls
# find / -type f -name "*.log" -print|xargs -I{} ls  -l {} #会立即有输出,即:find到一个便会有输出;find的每次结果都作为单次ls的输入即执行了n次ls;
-p参数会提示确认是否执行命令,通过-p参数可以看到上边两个命令的不同。
# find / -type f -name "*.log" -print|xargs -I{} -p  ls  -l {}
ls -l /configassist.log ?...y
-rw-r--r--    1 root     system            0 Jun 27 2012  /configassist.log
ls -l /etc/tunables/lastboot.log ?...y
-rw-r--r--    1 root     system          322 Jun 27 2012  /etc/t*****/lastboot.log
ls -l /home/cft/CFT/distrib/copilot/help_fr/translation cft 2_4.log ?...y
-rw-r--r--    1 cft      ftpgrp        25111 Jan 22 2009  /home/*******/copilot/help_fr/translation cft 2_4.log
ls -l /home/cft/mftlog/cftmonitor.log ?...

# find / -type f -name "*.log" -print|xargs  -p ls  -l       
ls -l /confi****sist.log /etc/tunables/lastboot.log /home/****/copilot/help_fr/translation cft 2_4.log /home/cft/****/cftmonitor.log /home/cft/****/cronclear_20120621.log /home/cft/****/cronclear_20120622.log /home/cft/***/cronclear_20120623.log …………………………………………………… /home/***/dba/dbload/oracle/ctl/tbl_user_inf.log?...
-n可以指定多少个输入执行一次后边的命令,因此当n设为1的时候效果跟-I一样。这样可以解决一些命令的参数需要单个输入的情况。
例子:查看连接8000的光纤卡的属性:
XXXXX:root:/>datapath query adapter |grep fscsi |awk '{print $2}' |xargs -n 1 lsattr -El
attach       switch    How this adapter is CONNECTED         False
dyntrk       yes       Dynamic Tracking of FC Devices        True
fc_err_recov fast_fail FC Fabric Event Error RECOVERY Policy True
scsi_id      0x140c00  Adapter SCSI ID                       False
sw_fc_class  3         FC Class for Fabric                   True
attach       switch    How this adapter is CONNECTED         False
dyntrk       yes       Dynamic Tracking of FC Devices        True
fc_err_recov fast_fail FC Fabric Event Error RECOVERY Policy True
scsi_id      0x20c00   Adapter SCSI ID                       False
sw_fc_class  3         FC Class for Fabric                   True

阅读(2581) | 评论(0) | 转发(3) |
1

上一篇:xmanager 无法连接到主机问题分析

下一篇:没有了

给主人留下些什么吧!~~