In Linux, there are always more than one ways of performing a task.
For example, to list all directories under /etc/ folder, you can issue:
$ls -ld /etc/*/
$find /etc/ -maxdepth 1 -type d
$ls -l | grep ^d
…
Can you come up with two ways of displaying only regular files under /etc/ folder ?
Displaying only regular files under /etc folder
1.Find command can be used to display regular files.
syntax: find /path option filename
find /etc/ -maxdepth 1 -type f -ls
>f is used for regular files.
>maxdepth 1 is used to stop the find command descending into subdirectories.
2.List command can be used to display regular files.
ls -l /etc/ | grep "^-"
> -l indicates regular file.
> grep command will return the lines starting with hyphen.
Get Answers For Free
Most questions answered within 1 hours.