Wednesday, April 23, 2008

List only Directory/Files in ls command

ls -l (include both directories and files)

ls -l | grep -v ^d (include only files in listing)

ls -l | grep ^d (include only directories in listing)

Tuesday, April 22, 2008

Read latest file in vi editor

In my daily routine on solaris box, i have to read the latest file in vi. For this i have to run below 2 commands:

ls -ltr
vi filename

I get the latest file name with ls -ltr command (last file in the list) and then vi to open this file.

I was sick of using 2 commands for this simple operation, so i thought of using a single command using combination of commands; following are the commands which I used for this operation:

vi `ls -ltr|tail -1|awk -F" " '{print $9}'` (includes directory listing)
vi `ls -ltr|grep -v ^d|tail -1|awk -F" " '{print $9}'` (ignores directory listing)
or
vi `ls -ltr|tail -1|cut -d":" -f2|cut -d" " -f2` (includes directory listing)
vi `ls -ltr|grep -v ^d|tail -1|cut -d":" -f2|cut -d" " -f2` (ignores directory listing)


Thursday, April 3, 2008

Location of firefox cookies ?

All the firefox cookies are stored in cookies.txt at C:\Documents and Settings\Windows login/user name\Application Data\Mozilla\Firefox\Profiles\profile folder