ls_usage
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ls_usage [2022/01/10 19:44] – [sort ls output by filename length] raju | ls_usage [2022/07/22 23:34] (current) – [indicators] raju | ||
---|---|---|---|
Line 3: | Line 3: | ||
ls --color=never --indicator-style=none | awk ' | ls --color=never --indicator-style=none | awk ' | ||
sort -n | cut -d" " -f2- | sort -n | cut -d" " -f2- | ||
+ | </ | ||
+ | |||
+ | To see it in action, create some files | ||
+ | < | ||
+ | % touch a ab abc | ||
+ | </ | ||
+ | |||
+ | and some directories | ||
+ | < | ||
+ | % mkdir d de def | ||
+ | </ | ||
+ | |||
+ | Output of the normal ls command | ||
+ | < | ||
+ | % ls | ||
+ | a ab abc d/ de/ def/ | ||
+ | </ | ||
+ | |||
+ | Output from the proposed command | ||
+ | < | ||
+ | % ls --color=never --indicator-style=none | awk ' | ||
+ | sort -n | cut -d" " -f2- | ||
+ | a | ||
+ | d | ||
+ | ab | ||
+ | de | ||
+ | abc | ||
+ | def | ||
</ | </ | ||
Line 27: | Line 55: | ||
-rwx------ 1 rajulocal rajulocal 1112 20201017 / | -rwx------ 1 rajulocal rajulocal 1112 20201017 / | ||
</ | </ | ||
+ | |||
+ | ==== indicators ==== | ||
+ | "ls -F" appends indicators < | ||
+ | * * means executable. | ||
+ | * / means directory. | ||
+ | * = means socket. | ||
+ | * > means door. | ||
+ | * @ means symbolic link (or that the file has extended attributes). | ||
+ | * | means named pipe. | ||
+ | |||
+ | Ref:- https:// | ||
+ | |||
+ | ==== only show filename and modification time ==== | ||
+ | < | ||
+ | ls -al | cut -d ' ' -f 6- | ||
+ | </ | ||
+ | |||
+ | Another way (using find): | ||
+ | < | ||
+ | find -maxdepth 1 -type f -printf "%TY %Tb %Td %TH: | ||
+ | </ | ||
+ | |||
+ | To sort the files based on timestamp (reverse chronological order) | ||
+ | < | ||
+ | find -maxdepth 1 -type f -printf " | ||
+ | </ | ||
+ | |||
+ | The %T+ is used to sort the output properly and gets removed by cut afterwards. | ||
+ | |||
+ | Ref:- https:// | ||
ls_usage.1641843860.txt.gz · Last modified: 2022/01/10 19:44 by raju