Solved 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). I believe libxo(3) support will return eventually.​
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, you may exceed LINE_MAX). Since FreeBSD version 15.0 find(1) output can be formatted.​
Bash:
# -s   : traverse file hierarchy in lexicographic order
# %20s : file size in bytes, padded with leading space so it occupies 20 cells
# %8Tc : file’s modification time expressed as preferred in current locale
# %f   : file name
find -s ./ -maxdepth 1 -printf '%20s  %8Tc  %f\n'
 
The purpose of the exercise was to change the output format of files in emacs's dired which I though could be controlled by various ls flags.

My intention is to get dired looking more like mc.

Now I have found out that this can be controlled using:-

(setq dired-hide-details-preserved-columns '(5 6 7 8))

so I think I can leave things there.

Many thanks to the people who made suggestions.
 
Back
Top