Physical Address
Metro Manila, Philippines
Physical Address
Metro Manila, Philippines
An ls (pronouced as el es) utility appeared in the original version of AT&T UNIX. Today, two popular versions of ls are the Free Software Foundation’s (part of the GNU coreutils package) and the one released by various BSD variants, such as FreeBSD, OpenBSD, NetBSD, and Apple Computer’s Darwin. Both are free software and open source.
The ls command is one of the most used and important command that we as linux user and linux/unix administrator can’t live without. It is the basic utility that a beginner must learn and one of the commands that a Unix/Linux administrator should not forget. In this article, we will explore on how we can use the ls more efficiently and take advantage about its power.
1. Opening the last file edited.
To open the last edited file in the current directory use the combination of ls, head and vi commands as shown below. ls -t sorts the file by modification time, showing the last edited file first. head -1 picks up this first file.
$ nano `ls -t | head -1`
Be aware with the tick `, because it is important to make the command work.
2. Display one file per line.
To display files and directories per line, use -1.
$ ls -1ApplicationsDesktopDocumentsDownloadsxincoClientConfig.dat
$ ls -ldrwxr-xr-x 2 johndoe staff 68 Feb 18 2011 Applicationsdrwx——+ 30 johndoe staff 1020 Feb 17 16:21 Desktopdrwx——+ 126 johndoe staff 4284 Feb 17 15:01 Documentsdrwx——+ 63 johndoe staff 2142 Feb 19 22:25 Downloads-rw-r–r– 1 johndoe staff 20960 Jun 6 2011 xincoClientConfig.dat
$ ls -l-rw-r–r– 1 johndoe staff 20960 Jun 6 2011 xincoClientConfig.dat
$ ls -lh-rw-r–r– 1 johndoe staff 20K Jun 6 2011 xincoClientConfig.dat