rss feed Twitter Page Facebook Page Github Page Stack Over Flow Page

Customized folder and file

List folders and files in Linux is commonly used in Linux. Using the common output is, as well, common and can be pretty boring. Here's a quick way to display list of folders and files that will suit more your needs.

List only folders

ls -l | grep ^d | awk '{print "\033[1;32;40m"$8"/\033[0m"}'

List only files

ls -lh | grep -v ^d | egrep -v 'total(.*)' | awk '{print "\033[1;34;40m"$8" \033[1;32;40m("$5")\033[0m"}'

List only files and folders

ls -hl | grep -v total | awk '{ if($1 !~ '/^d/') { print "\033[1;34;40m"$8" \033[1;32;40m("$5")\033[0m" } else { print "\033[1;32;40m"$8"/\033[0m" } }'

Here's a quit guide that will help you change the colors if you don't like mine!

Syntax:
\033[Attribute codes;Text color codes;Background color codesmsome random text\033[0m

Attribute codes:

00=none
01=bold
04=underscore
05=blink
07=reverse
08=concealed

Text color codes:

30=black
31=red
32=green
33=yellow
34=blue
35=magenta
36=cyan
37=white

Background color codes:

40=black
41=red
42=green
43=yellow
44=blue
45=magenta
46=cyan
47=white