Sunday, September 9, 2012

Third session of Some of basic UNIX commands that are useful very frequently

Hey Folks,

Am back for continuing on posting some more of UNIX commands that are useful whenever you are using any UNIX based operating System.

Grep is a command which is useful for searching any word/name of file/partial name of file in a working directory or any path mentioned. This will display with both case sensitive and case-insensitive results based on the command specified..

grep -i "searchword" FILE

Above command will search for 'searchword' in file named 'FILE' and display matching lines in that file as a result.

We can also use regular expressions to search as per our requirements.

grep "string.*string1" file

Above command will display any line that has 'string' starting with and 'string1'ending with and anything in between... in the file named 'file'.

A regular expression may be followed with one of the following operators.

? The preceding item is matched with at most one time.
* The preceding item is matched with zero or more times.
+ The preceding item is matched with one or more times.
{n,m} The preceding item is matched with minimum 'n' times and maximum 'm' times.

Like this you can use of regular expression for searching your patterns.

In this way 'grep' is useful for searching purpose. There are many more uses of this command that you can know by hitting command 'man grep' in your unix/linux based operating system's terminal(you can call it as cmd prmpt in terms of windows).

shutdown is a command in unix that is useful for letting your system down. You can shutdown your machine immediately or after a specified time..

shutdown -t 2

Above command will shutdown the system securely after 2 seconds.

shutdown -r

Above command will reboot your machine securely..

shutdown -c

Above command will cancel shutdown job that is already running..

As specified above there are many more uses of this command that u can get to know by hitting 'man shutdown' in your terminal..

Will specify some more in next post...

No comments: