Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Feb 082010
 

How to get the file creation time?

Answer:

Linux never stores file creation time.

You can only get access, modify & change (change of status, e.g. permission) time of a file with stats command

# stats test.txt

stat test.txt
  File: `test.txt'
  Size: 25557           Blocks: 56         IO Block: 4096   regular file
Device: ca01h/51713d    Inode: 32714       Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1001/    user)   Gid: ( 1000/ user)
Access: 2010-01-02 18:53:46.000000000 +0800
Modify: 1970-01-01 17:13:08.000000000 +0800
Change: 2010-01-02 18:53:46.000000000 +0800
Feb 072010
 

How to perform checksum on a folder?

Answer:

Previous article told you how perform checksum on a file. How about to perform checksum on a folder?

A simple solution is to install md5deep

# sudo apt-get install md5deep

To perform checksum on a particular folder (input),

#  md5deep -l -r input

26ab0db90d72e28ad0ba1e22ee510510  input/2.txt
6d7fce9fee471194aa8b5b6e47267f03  input/3.txt
b026324c6904b2a9cb4b88d6d61c81d1  input/1.txt

That's so easy.

Reference: http://md5deep.sourceforge.net/

Feb 062010
 

Wait for a process terminated

Answer:

wait command allow you to monitor the termination of a process and quit afterward.

It is very useful when you want to trigger some action when a particular process terminated.

E.g. Send an email when a long running process of PID 5870 terminated

#  wait 5870 && echo Finished | mail -s Task [email protected]
Feb 052010
 

Remove directory name from file path

Answer:

It is easy to use basename to remove directory name from file path

E.g.

# basename /tmp/test.txt
test.txt

# basename /tmp/test.txt .txt
test

If you supply the 2nd argument, it will remove the characters if they exist in the suffix of the input filename.