..MindWrite..

Posts Tagged ‘shell’

remove front spaces from a string

Posted by guptaradhesh on November 8, 2010

a simple sed command to do the same is as:

sed -e 's/^ *//' data
Advertisements

Posted in tech, unix | Tagged: , , | 1 Comment »

Unix mtime, ctime, atime

Posted by guptaradhesh on November 1, 2010

ctime: is the inode change time. When does the inode change, when you of course update a file, but also when you do things like changing the permissions of the file but not necessarily its contents. We can view the ctime with the ls -lc command.

atime: stands for access time which is when the file was last read. Displaying the contents of a file or executing a shell script will update a file’s atime. We can view the atime with the ls -lu command.

mtime: is the modification time, so if you change the contents of the file, this time is updated. Keep in mind when you change the contents of a file and and save it, the inode gets updated as well for that file, so ctime always changes too. We can view this with ls -l.

Therefore, when mtime changes, ctime will always change.

Posted in tech, unix | Tagged: , , , , | Leave a Comment »

Special parameters in UNIX Shell

Posted by guptaradhesh on October 24, 2010

$# Number of positional parameters

$? Exit value of last executed command

$$ Process number of current process

$! Process number of background process

$* All arguments on command line

“$@” All arguments on command line ,  individually quoted “$1” “$2” …

$-    Options currently in effect

Posted in tech | Tagged: , , , | Leave a Comment »

What exactly does this command does: echo $?

Posted by guptaradhesh on October 24, 2010

It displays the exit status of previous unix command.

Every Linux command executed by the shell script or user, has an exit status. The exit status is an integer number. 0 exit status  means the command was successful without any errors. A non-zero (1-255 values) exit status means command was failure.

 

Posted in tech | Tagged: , , | Leave a Comment »