More significance of “ “

•July 21, 2008 • Leave a Comment

While testing conditions it would be better to use double quotes as follows

If [ “$VAR” = “value” ]

So that if a blank value comes as the value of the variable VAR, it will not generate any error.

What is the significance of &

•July 14, 2008 • Leave a Comment

We usually treat & as the address of variable. The same feature is incorporated in Unix as well. This is for redirecting the outputs from different operations.

For eg: ps >> /dev/null 2>&1

This is telling the kernel to put the error along with the normal outputs to the same file. &1 refers to the

filename that is referred for the standard output.

Why we use ./ while running a script.

•July 14, 2008 • Leave a Comment

As we all know there is PATH environmental variable. And some paths will be defined for this. When we give a script name as such, the shell will search for this script name in those paths and if not found, the script will not get executed. This is why sometimes we get the error saying that the specified script not found. So to avoid this, either you add the pathname where your scripts resides to the PATH variable or run the job as ./ [ if your job is in the current directory where you are standing] or give the absolute path for running the job.

.

Searching

•July 11, 2008 • Leave a Comment

Most useful part. Listing the commands used in unix to achieve this.
grep
egrep
fgrep
find
strings

grep

•July 11, 2008 • Leave a Comment

Damn good search engine…will get the results in different fashions even


grep -lR   gives out the files having the searching pattern

grep -nR  lists out the lines that matched

find

•July 11, 2008 • Leave a Comment

The most useful Command for me. Used it to search for a file that is last accessed modified or for a file whose path is not known to me

find -cmin -20  -> finds out the files last modified within last 20 minutes or lesser than that in the preset working directory

find -name “file” -> search for a particular file

Lot more options are available. Listed the 2 I most used.

Strings

•July 11, 2008 • Leave a Comment

Prints the strings of printable characters in a file.
I used this for a search in core files…

Can be used to explore the strings in a binary file