Saturday, October 29, 2005

Files and folders in a directory with ls and dir - Programming One Liner 5 - 10

Contents of a directory


This programming one liner allows you to see what files and directories are available within a folder on your Linux web server. Upon invocation of this one liner, the contents of your current directory (pwd) will be displayed.


ls


If you believe your ls binary is corrupt (due to a server hack) or just to use an alternate command, you can use the following command on Linux server to get the same results. dir and ls are infact two different binaries.


Programming One Liner # 6

dir



The following one liner will let you view detailed information about files and directories within your present directory. This command is commonly termed as "long listing format".


Programming One Liner # 7

ls -l


Similarly, you can use the long listing option with dir command.


Programming One Liner # 8

dir -l



This command can be used to view the listings with color codings (if supported by your Linux web server).


Programming One Liner # 9

ls --color=tty



To make the color coded listings part of your profile, simply add the following lines to your .bash_profile directory. You can also execute this command to just color code the listings for your current session.


Programming One Liner # 10

alias ls='ls --color=tty'




Programming "One Liner" lookup terms:
ls dir

USE THIS PROGRAMMING ONE LINER AT OWN RISK AS AUTHOR CLAIMS NO RESPONSIBILITY.
If you would like more information on any of the commands, please feel free to contact me with your . You can also read other posts on programming code, lookup the programming terms displayed above or visit my network security blog. Other external programming blogs on Technorati and programming blogs on Google.

No comments: