ls output format

we would avoid doing this. the output of ls is not stable or parseable, it is for humans to read.
Sure, I myself would go with stat(1) as covacat suggested, but just as a quick, dirty, but working solution.

By the way, I didn't know that the output of ls(1) is not stable. Does that mean that say -l output can potentially be different in different systems (implementations)?
 
yeah. linux ls -l has a different output format than bsd ls -l, plus the user's environment can unduly affect the output format too. or you'll upgrade and the format will change. thus, we never parse the output of ls.
 
The output of ls is implementation‑defined if the destination is a terminal. Pipe it and you’re fine (if the ls implementation claims to be POSIX™‐compliant).​
Are there any command line switches to format the output of ls() so that it only shows name size and time?
To answer your question: No.​
stat -f "%N %z %Sm" -t "%Y-%m-%d %H:%M:%S" *
I don’t like having the shell expand file names. Consider a directory containing many long file names. Since FreeBSD version 15.0 find(1) output can be formatted.​
Bash:
find -s ./ -maxdepth 1 -printf '%20s  %8Tc  %f\n' # s: bytes; Tc: mod t (in locale) f: file name
 
Back
Top