------------------------------------------------------
NOTES : Sample code for [ ls ] command...
------------------------------------------------------
# DISPLAY HIDDEN FILES SHORT
# .bash_history
alias lhs='ls -a | grep "^\.[a-zA-Z]"'
ls -a | grep "^\.[a-zA-Z]"
# DISPLAY HIDDEN FILES LONG
# -rw------- 1 bhernand bhernand 5156 May 12 19:46 .bash_history
alias lhl='ls -la | grep " \.[a-zA-Z]"'
ls -la | grep " \.[a-zA-Z]"
# LIST CURRENT DIRECTORY AND SORT BY THE 9TH COLUMN (FILENAME)
ls -lF | sort -k 9
# LIST CURRENT DIRECTORY AND REVERSE SORT BY THE 9TH COLUMN (FILENAME)
ls -lF | sort -r -k 9
# LIST CURRENT DIRECTORY RECURSIVELY AND SORT BY THE 9TH COLUMN (FILENAME)
cd ~/unix_scripts/
ls -RlF | sort -k 9
# LIST RECURSIVELY THE SPECIFIED DIRECTORY AND SORT BY THE 9TH COLUMN (FILENAME)
ls -RlF ~/unix_scripts/ | sort -k 9
# This next line semi solves the DATE/TIME problem.
# You either have to check against month/day, or just accept that the year might be off by one.
dir=/Some/Path/To/Server ; y=`date +%Y`; ls -lR $dir | sed -e "s/[0-9]*:[0-9]*/ `echo ${y}`/g"
# Try this, it will give you the {permissions, owner, group, name} sorted by permissions
ls -ls /Users/Shared/debug_do_not_throw | awk '{print $2" "$4" "$5" "$10}' | sort -k 1
# Try this, it will give you the fiels only {permissions, owner, group, name} sorted by {name, permissions}
dir=/Users/Shared; ls -lR $dir | grep "^[-]" | awk '{print $1" "$3" "$4" "$9}'| sort -fk 9 | sort -fk 1
# Try this, it will give you the directories only {permissions, owner, group, name} sorted by {name, permissions}
dir=/Users/Shared; ls -lR $dir | grep "^[d]" | awk '{print $1" "$3" "$4" "$9}'| sort -fk 9 | sort -fk 1
# THESE ARE REALLY HANDY:
# The two commands below make it very easy to scan the permissions for a whole directory hierarchy,
# in order to see if anything looks out of place. The funny thing is that nothing aligns correctly.
# The display is not uniform at all within the last three or four fields.
# LIST ALL DIRECTORIES :
# 1st level sort on [permissions and size] and 2nd level sort on [dirname]
$ dir=/Some/Path/To/WebServer; ls -lR $dir | grep "^[d]" | sort -fk 9 | sort -fk 1
# LIST ALL FILES :
# 1st level sort on [permissions and size] and 2nd level sort on [filename]
$ dir=/Some/Path/To/WebServer; ls -lR $dir | grep "^[-]" | sort -fk 9 | sort -fk 1
Best Regards,
Bill Hernandez
Plano, Texas