Been long time since I used this command, only today I had a chance to try it again, and to my surprise it still works ! Previously I use this under SUN Solaris unix, it still works when I tested it on FreeBSD 5.x.

The simplest example by executing the ls -al command:

user1% ls -al
total 24
drwx------ 2 user1 users 4096 Feb 21 14:37 ./
drwx-----x 14 user1 users 4096 Feb 21 14:37 ../
-rw------- 1 user1 users 36 Feb 21 14:36 file1.txt
-rw------- 1 user1 users 60 Feb 21 14:37 file2.txt
-rw------- 1 user1 users 144 Feb 21 14:37 file3.txt
-rw------- 1 user1 users 96 Feb 21 14:37 file4.txt

lets just say we would like to execute ls command again but this time we want a different option, instead of -al which gaves a long listing, we just want a simple output of the filenames only. This can be done by using the -1 option in ls command. So we know that previous command is ls -al, and next we want to run ls -1, the only different is in the option, just replace the -al with the -1.

Try this:

user1% ls -al
total 24
drwx------ 2 user1 users 4096 Feb 21 14:37 ./
drwx-----x 14 user1 users 4096 Feb 21 14:37 ../
-rw------- 1 user1 users 36 Feb 21 14:36 file1.txt
-rw------- 1 user1 users 60 Feb 21 14:37 file2.txt
-rw------- 1 user1 users 144 Feb 21 14:37 file3.txt
-rw------- 1 user1 users 96 Feb 21 14:37 file4.txt
user1% ^al^1
ls -1
file1.txt
file2.txt
file3.txt
file4.txt
user1%

We use the upper-caret character (^) to first specify the word/characters from previous commands that we wanted to be replaced, and then the new word/characters that we want to replace it with. As simple as that.

Tags: , , ,

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>