![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| File timestamp | stevefox | UNIX for Dummies Questions & Answers | 4 | 12-24-2007 10:14 PM |
| ftp - get file and keep original timestamp? | frustrated1 | Shell Programming and Scripting | 2 | 03-15-2006 10:31 AM |
| comparing timestamp of two files | jyotipg | Shell Programming and Scripting | 2 | 04-06-2004 03:38 AM |
| timestamp of file | krisdhar | UNIX for Dummies Questions & Answers | 4 | 10-28-2003 07:31 AM |
| retrieve timestamp associated with a file | 2nilotpal | UNIX for Dummies Questions & Answers | 2 | 08-08-2002 03:23 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I'm new to unix,I wanna know how can I compare timestamp of a file with its touched version.i.e I want to be sure if the touch command has worked properly i.e if the file has been touched then a msg should be printed saying success else failure.All this to be incurred in a script. Any suggestions are welcome. Thanks in advance |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
If the stat(1) utility is available, then here is an example of one way of doing it
Code:
#!/bin/bash FILE=./testfile # replace with your file stat1=$(stat --printf="%Z" $FILE) touch $FILE stat2=$(stat --printf="%Z" $FILE) if [[ $stat1 = $stat2 ]] then echo "touch failed" else echo "touch succeeded" fi |
|
#3
|
||||
|
||||
|
Quote:
check for $? after that command e.g Code:
touch filename if [ $? -eq 0 ];then echo "done" else echo "not done" fi |
||||
| Google The UNIX and Linux Forums |