Category Archives: Daily Hacks

Hack #11-> Join Command

Join command combines lines from two files based on a common field. In the example below, we have two files – employee.txt and salary.txt. Both have employee-id as common field. So, we can use join command to combine the data from these two files using employee-id as shown below. $ cat employee.txt 100 Jason Smith 200 John Doe 300 Sanjay

Read more

Hack #10-> Suppress Standard Output and Error Message

Sometime while debugging a shell script, you may not want to see either the standard output or standard error message. Use /dev/null as shown below for suppressing the output. Suppress standard output using > /dev/null This will be very helpful when you are debugging shell scripts, where you don’t want to display the echo statement and interested in only looking

Read more

Hack #9-> Find Command

Find is frequently used command to find files in the UNIX filesystem based on numerous conditions. Let us review some practice examples of find command. Syntax: find [pathnames] [conditions] How to find files containing a specific word in its name? The following command looks for all the files under /etc directory with mail in the filename. # find /etc -name

Read more

Hack #7-> Grep Command

Grep command is used to search files for a specific text. This is incredibly powerful command with lots of options. Syntax: grep [options] pattern [files] How can I find all lines matching a specific keyword on a file? In this example, grep looks for the text John inside /etc/passwd file and displays all the matching lines. # grep John /etc/passwd

Read more
« Older Entries Recent Entries »