感谢支持
我们一直在努力

ls -l –time-style命令查看文件是星期几创建的几种方法

查看文件是星期几创建的几种方法总结了以下三种方法:
1.使用ls命令结合grep的方法:
ls -l –time-style ‘+%A’ | grep -E “Tuesday|Wednesday”
2.使用AWK的方法1:
[Oracle@bys3 ~]$ ls -l –time-style ‘+%A’|awk ‘$6==”Friday”||$6==”Tuesday” {print $0}’
-rw-r–r– 1 oracle oinstall 253 Friday archback.sh
-rw-r–r– 1 oracle oinstall 199 Friday bbedfile.txt
-rw-r—– 1 oracle oinstall 1958583 Friday bys3_ora_13020.trc
-rw-r–r– 1 oracle oinstall 350 Tuesday delarch.sh
drwxr-xr-x 3 oracle oinstall 4096 Tuesday oradiag_oracle
[oracle@bys3 ~]$

3.使用AWK的方法2: –有点复杂了
declare -a array
array=(`ls -l –time-style ‘+%A’ | awk ‘{print $6}’`)
echo ${array[0]}
length=${#array[@]}
echo $length
for ((i=0;i<$length;i++))
do
case ${array[$i]} in Tuesday|Wednesday)
ls -l –time-style ‘+%A’ | grep -E ${array[$i]}
esac
done
~
4.ls -l –time-style命令的几种用法示例: –可以把常用的在环境变量写成alias ls=’ ‘
[oracle@bys3 ~]$ ls -l –time-style=”+%Y-%m-%d $newline%m-%d %H:%M” –显示了详细的年月日时分
total 1964
-rw-r–r– 1 oracle oinstall 17 2013-12-04 12-04 14:09 10
lrwxrwxrwx 1 oracle oinstall 46 2013-12-01 12-01 22:53alert_bys3.log -> /u01/diag/rdbms/bys3/bys3/trace/alert_bys3.log
-rw-r–r– 1 oracle oinstall 253 2013-11-15 11-15 21:25 archback.sh
[oracle@bys3 ~]$ ls -l –time-style=”iso”
total 1964
-rw-r–r– 1 oracle oinstall 17 12-04 14:09 10
lrwxrwxrwx 1 oracle oinstall 46 12-01 22:53 alert_bys3.log -> /u01/diag/rdbms/bys3/bys3/trace/alert_bys3.log
-rw-r–r– 1 oracle oinstall 253 11-15 21:25 archback.sh
[oracle@bys3 ~]$ ls -l –time-style=”+%b %e %Y$newline%b %e %H:%M”
total 1964
-rw-r–r– 1 oracle oinstall 17 Dec 4 2013Dec 4 14:09 10
lrwxrwxrwx 1 oracle oinstall 46 Dec 1 2013Dec 1 22:53alert_bys3.log -> /u01/diag/rdbms/bys3/bys3/trace/alert_bys3.log
-rw-r–r– 1 oracle oinstall 253 Nov 15 2013Nov 15 21:25 archback.sh
[oracle@bys3 ~]$ ls -l –time-style=”locale”
total 1964
-rw-r–r– 1 oracle oinstall 17 Dec 4 14:09 10
lrwxrwxrwx 1 oracle oinstall 46 Dec 1 22:53 alert_bys3.log -> /u01/diag/rdbms/bys3/bys3/trace/alert_bys3.log
-rw-r–r– 1 oracle oinstall 253 Nov 15 21:25 archback.sh

赞(1) 打赏
转载请注明出处:服务器评测 » ls -l –time-style命令查看文件是星期几创建的几种方法
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏