处理这种方式的方法就是借助awk,其实,使用cut也可以
下面的命令打印第5行
awk ‘{print $5}’ filename
打印多列数据,并且在列间插入制定的字符串
比如获取到各个文件的权限和文件名
ls -l | awk ‘{print $1 “:” $8}’
[locker@deploy ~]$ ls -l|awk ‘{print $1 “:” $9}’
total:
drwxr-xr-x.:Desktop
drwxr-xr-x.:Documents
drwxr-xr-x.:Downloads
-rw-r–r–.:dump.rdb
-rw-rw-r–.:hs_err_pid5521.log
drwxrwxr-x.:logs
drwxr-xr-x.:Music
drwxr-xr-x.:Pictures
drwxr-xr-x.:Public
drwxr-xr-x.:rpmbuild
-rw-rw-r–.:rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
drwxr-xr-x.:Templates
-rwxrwxr-x.:testFunction.sh
drwxrwxr-x.:tools
drwxr-xr-x.:Videos