Linux Tips and Tricks

Linux Tips and Tricks

List the Directory Name


We can use the below commands to display only the directory names

$ echo */
Scripts/ unix-commands-cheat-sheet_files/

$ printf “%s\n” */

$ ls -d */
Scripts/  unix-commands-cheat-sheet_files/

$ ls -l | grep ^d
drwxr-xr-x 2 kamaraj kamaraj    4096 2011-03-11 21:25 Scripts
drwxr-xr-x 4 kamaraj kamaraj    4096 2011-02-09 01:11 unix-commands-cheat-sheet_file

$ find . -maxdepth 1 -type d

posted under Uncategorized | No Comments »

Retrieve the last executed command


In linux we can easily get the last executed command using the below command.

echo “!!”

execute the last executed command by simply typing two !!


you can easily redirect the output into one more script file.

echo “!!” >

posted under Uncategorized | No Comments »

Exceute shell script without assign execute permission


Create a simple shell script as follows.

echo “Hello World”

save the file as hello_world

And now you can see the file permission using the ls -l command.

$ ls -l hello_world
-rw-r–r– 1 kamaraj kamaraj 19 2011-03-11 20:40 hello_world

Now type sh hello_world in the terminal.

$ sh hello_world
hello world

posted under Uncategorized | No Comments »

Recent Comments