I have an ll function that is currently expanding:
function ll () { ls -lh --color " $@ " | grep "^d"; ls -lh --color " $@ " | grep "^-" | grep -v "~"; ls -lh --color " $@ " | grep "^l" }
What this does is sort the specified folder, displaying folders first, then files, then links. However, I find that this approach reduces the functionality of the ls , for example, if I try to call ll /bin /tmp , I get a combination of files from both folders.
Is there a general rule for passing command aliases / functions, so that the full functionality of these commands does not decrease? If this does not happen, how can I fix my ll command to save the sort, but the full functionality of ls not lost?
Note that I currently have bash version 3.2.25 (1) -release on my system (ls version 5.97), so the --show-directories-first flag is not available to me.
EDIT:
This is the function I ended up using, I changed it a bit so that ll work without any arguments:
function ll () { if [ $# -eq 0 ]; then set -- .; fi for d; do ls -lh --color "$d"|awk '$1~/^d/{i=0} $1~/^l/{i=1} $1~/^-/{i=2} NF>2{print i OFS $0}' | sort -n -k1,1 | cut -d ' ' -f2- done }
source share