TIP_dirs_and_files_in_ls
| Terminals / Shells • Network • X Window System • Portage • System • Filesystems • Kernel • Other |
Contents |
Distinguishing directories from files in ls
Normally when you type 'ls' in the console you won't be able to distinguish regular files from directories. There is more than one way to make 'ls' show the difference.
Long listing
ls -l
Each file's description will fill a line, the first character of a line shows the type:
- - regular file
- d directory
- l link
- c character device
- b block device
| Code: ls -l |
drwxr-xr-x 10 user users 4096 jan 1 2005 directory -rw-r--r-- 1 user users 25721 jan 1 2005 me.jpeg -rwxr--r-- 1 user users 325 jan 1 2005 script.sh |
Classify
ls --classify or ls -F will append characters to files to show their type:
- / directory
- * executable
| Code: ls -F |
directory/ me.jpeg script.sh* |
Color
ls --color=tty
Will color the 'ls' output. Directories are blue, regular files stay black (or white) and executable files are green.
directory me.jpeg script.sh
Convenience
Make an Alias of your prefered method.
Example:
alias ls='ls --color=tty --classify'
List only directories
ls -d */
Will list only entries ended by a "/", and with the "-d" option, will not descend into the next level of directory.
Last modified: Sat, 06 Sep 2008 09:10:00 +1000 Hits: 16,492
Created by NickStallman.net, Luxury Homes Australia
Real estate agents should be using interactive floor plans and real estate agent tools.
