I for one do NOT like intermingling of hidden and non-hidden files. Similarly, I don’t like mingling letters and special characters when sorting.
I am very particular with my sorting of files and directories at command line, so I use a couple of different things.
[1] This first is a function used by other alias definitions (to ensure uniform presentation of information, regardless of the displayed content encountered):
alias ndate='awk '\''{ pos=index( $0, $9 ) ; rem=substr( $0, pos ) ; printf("%s %3d %10s %10s %10d %3s %2d %5s %s\n", $1, $2, $3, $4, $5, $6, $7, $8, rem ) ; } '\'' '
[2] Then, to list only directories, I have
alias ldir='find . -maxdepth 1 -type d -print | cut -c3- | sort -V | xargs -I here ls -ld --color=always "here" | ndate '
[3] Similarly, for non-directory files, I have
alias lf='find . -maxdepth 1 \( ! -type d \) -print | cut -c3- | sort -V | xargs -I here ls -ld --color=always "here" | ndate '
[4] To report only shell scripts in the current directory:
alias lsh='find . -maxdepth 1 \( -name "*.sh" -o -name "*.bash" \) -print | cut -c3- | sort -V | xargs -I here ls -ld --color=always "here" | ndate '
[5] And again, for only symbolic links:
alias lsk='find . -maxdepth 1 -type l -print | cut -c3- | sort -V | xargs -I here ls -ld --color=always "here" | ndate '
[6] To list everything, using that same formatting and ordering, I have:
alias lf='find . -maxdepth 1 \( ! -type d \) -print | cut -c3- | sort -V | xargs -I here ls -ld --color=always "here" | ndate '
On the more complicated side, I have this script [Priority__Report.sh]:
#!/bin/sh
BASE=`basename "$0" ".sh" `
TMP=/tmp/${BASE}.proclist
rm -f ${TMP}
ps -eo pid,user:15,%cpu,ni,args >${TMP}
header="`head -1 ${TMP} `"
echo "${header}"
if [ "$1" = "--all" ]
then
tail -n +2 ${TMP}
else
tail -n +2 ${TMP} | awk '{ if( $4 != "-20" && index($5,"[kworker/") != 1 && index($5,"[ksoftirqd/") != 1 && index($5,"[jbd2/") != 1 && index($5,"[scsi_eh") != 1 && index($5,"[idle_inject") != 1 && index($5,"[migration") != 1 && index($5,"[cpuhp") != 1 ){ print $0 } ; }'
fi | sort -n --key=3.1,4.0 | sort --key=2.1,3.0
rm -f ${TMP}
[7] for which I use the following alias:
alias prio='/Oasis/bin/Priority__Report.sh'
[Edit:] While sharing the above, I noticed that I had a gap in my “reporting” aliases, one giving only the hidden files at current directory level. I just added this [8] to my environment:
alias ldot='find . -maxdepth 1 -print | cut -c3- | grep ^[.] | sort -V | xargs -I here ls -ld --color=always "here" | ndate '