Get file time stamp
(1) View all information: Stat e4.txt Example: [[email protected] ~]# stat e4.txt File: "E4.txt" size:0 blocks:0 IO block:4096 General empty file device:806h/2054d inode:486265 links:1access: (0644/-rw-r--r--) Uid: (0/root) Gid: (500/whuang) access:2002-03-23 10:23:33.000000000 +0800modify:2002-03-23 10:23:33.000000000 +0800change:2012- 08-16 14:15:13.000000000 +0800 (2) View last access time stat-c%x e4.txt Example: [[email protected] ~]# stat-c%x e4.txt2002-03-23 10:2 3:33 +0800 (3) View last modified stat-c%y e4.txt Example: [[email protected] ~]# stat-c%y e4.txt2002-03-23 10:23:33.000000000 +0800 (4) View last changed time Stat-c%z e4.txt Example: [[email protected] ~]# stat-c%z e4.txt2012-08-16 14:15:13. 000000000 +0800 There are two different ways: [[[email protected] ~]# ls--full-time e4.txt-rw-r--r--1 root whuang 0 2002-03-23 10:23:33.0 00000000 +0800 e4.txt-------------------------------------------------[[email protected] ~]# perl-le ' Print Scalar (localtime ((Stat ("./e4.txt")) [9])) ' Sat MaR 23 10:23:33 2002
------------------------------------------------------------determine if the file exists:
#shell判断文件夹是否存在 # If the folder does not exist, create a folder if [!-D "/myfolder"]; Then Mkdir/myfolderfi#shell determine the file, whether the directory exists or has permissions folder= "/var/www/" file= "/var/www/log" #-x parameter to determine $folder Whether it exists and has enforceable permissions if [!-X ' $folder]; Then mkdir the "$folder" fi#-D parameter to determine if there is an IF [!-D "$folder"]; then mkdir "$folder" fi#-F parameter to determine if $file exists if [! -F "$file"]; Then touch "$file" fi#-N to determine if a variable has a value if [!-n "$var"]; then echo "$var is empty" exit 0fi# determine if two variables are equal if ["$va R1 "=" $var 2 "]; Then echo ' $var 1 eq $var 2 ' else echo ' $var 1 not EQ $var 2 ' fi
Linux gets file time information to determine if a file exists