ls命令
ls对文件mtime时间进行排序
降序: ls -lt | grep '^-'
升序: ls -ltr | grep '^-'
seq命令
求1000以内所有偶数的和
echo `seq 0 2 1000` | tr -s ' ' + | bc
paste命令
用户名-密码-家目录路径-默认shell
这里需要注意paste 文件的先后顺序问题,不同的顺序会有不同的结果 -f 只能从小到大依次显示,不能调整显示顺序.所以可以通过
调整 paste file1 file2 或者 paste file2 file1 来实现对列的顺序显示.
paste -d: /etc/shadow /etc/passwd | grep "^\<$root\>" | cut -d: -f1,2,15,16
[root@centos7 ~]# paste -d: /etc/passwd /etc/shadow | grep '^\<root\>:'|cut -d: -f1,9,6,7
虽然在后面指定-f1,9,6,7显示,但是最终显示结果还是按照1,6, 7, 9来排列的.这种指定无效.
root:/root:/bin/bash:$6$RzUIKaLkncGUm9SL$FtuXzR8IpSz2OEQp.LlDrDH1O62SMrZ/Gj06iTSNqlxWma/aHf21lpikhNln6UgNyuL/HqGUrM45feTBkMC1T0
date 命令
[root@centos7 sysconfig]# date +%F 2018-04-17 [root@centos7 sysconfig]# date +%H:%M:%S 19:56:29 [root@centos7 sysconfig]# date -d "$v_date -1 year" +%Y 2017 [root@centos7 sysconfig]# date -d last-year +%Y 2017 [root@centos7 sysconfig]# date -d next-year +%Y 2019 [root@centos7 sysconfig]# date -d next-year +%Y%M 201958 [root@centos7 sysconfig]# date -d next-year +%Y%M 201958 [root@centos7 sysconfig]# date -d next-year +%Y%m 201904 [root@centos7 sysconfig]# date -d next-year +%Y%m%D 20190404/17/19 [root@centos7 sysconfig]# date -d next-year +%Y%m%d 20190417