当不用时:
[root@centos7 temp]# find . -name "file*" | xargs ls ls: 无法访问./file: 没有那个文件或目录 ls: 无法访问14: 没有那个文件或目录 ./file10 ./file11 ./file12 ./file13
选项-I string为输入项目指定替代字符串:
[root@centos7 temp]# ls abcd/
[root@centos7 temp]# find . -name "file*" | xargs -I{} mv {} abcd/
[root@centos7 temp]# ls abcd/
file10 file11 file12 file13
[root@centos7 temp]#
这里的意思是说使用-I后面的字符串去代替输入项目,这样就可以把它们作为整体放到命令的任意位置来执行了。也避免了-exec command {} +的错误。
选项-d指定输入项目的分隔符:
[root@centos7 temp]# head -n1 /etc/passwd root:x:0:0:root:/root:/bin/bash [root@centos7 temp]# head -n1 /etc/passwd|xargs -d ":" echo -n root x 0 0 root /root /bin/bash [root@centos7 temp]#
选项-P指定最大进程数,默认进程数为1,多个进程并发执行。
3、date 打印或设置系统时间
date [OPTION]... [+FORMAT]
当没有任何参数时表示显示当前时间:
[root@centos7 temp]# date 2016年 11月 01日 星期二 15:30:46 CST [root@centos7 temp]#
选项-d string按描述字符串显示时间(例子中字符串表示距离1970-01-01零点的秒数):
[root@centos7 temp]# date --date='@2147483647' 2038年 01月 19日 星期二 11:14:07 CST
或者:
[root@centos7 temp]# date -d@2147483647 2038年 01月 19日 星期二 11:14:07 CST
-d后面的字符串还可以是:
[root@centos7 temp]# date -d "-1 day" 2016年 10月 31日 星期一 16:11:27 CST
表示昨天
又如明年表示为:
[root@centos7 temp]# date -d "1 year" 2017年 11月 01日 星期三 16:12:27 CST
选项-s设置系统时间:
[root@centos7 temp]# date -s "2016-11-01 15:49" 2016年 11月 01日 星期二 15:49:00 CST [root@centos7 temp]# date 2016年 11月 01日 星期二 15:49:03 CST
由于linux系统启动时将读取CMOS来获得时间,系统会每隔一段时间将系统时间写入CMOS,为避免更改时间后系统的立即重启造成时间没有被写入CMOS,通常设置完时间后会使用命令clock -w将系统时间写入到CMOS中。
date命令中由FORMAT来控制输出格式,加号+在格式之前表示格式开始:
[root@centos7 temp]# date "+%Y-%m-%d %H:%M:%S" 2016-11-01 16:00:45 [root@centos7 temp]#
本例中格式被双引号引起来以避免被shell误解,其中:
%Y 表示年
%m 表示月
%d 表示天
%H 表示小时
%M 表示分钟
%S 表示秒
还可以指定很多其他格式如只输出当前时间:
[root@centos7 temp]# date "+%T" 16:03:50 [root@centos7 temp]#










