Discussion:
bug#33577: ls lacks null terminator option
(too old to reply)
積丹尼 Dan Jacobson
2018-12-02 10:53:06 UTC
Permalink
For files with blanks in their names,
one shouldn't need this workaround:
$ ls -t | tr \\n \\0 | xargs -0 more > /tmp/z.txt
Please add a --print0 option. like find(1) has.

ls (GNU coreutils) 8.30
Bob Proulx
2018-12-03 19:55:30 UTC
Permalink
Post by 積丹尼 Dan Jacobson
For files with blanks in their names,
$ ls -t | tr \\n \\0 | xargs -0 more > /tmp/z.txt
Please add a --print0 option. like find(1) has.
I think that adding a --print0 option to 'ls' is not wise because it
would suggest to people seeing it that 'ls' should be used in scripts.
But 'ls' is a command designed for human interaction not for use in
scripts. Using 'find' for scripted use is the desired utility.

Such a patch has previously been submitted.

http://lists.gnu.org/archive/html/coreutils/2014-02/msg00005.html

Bob
積丹尼 Dan Jacobson
2018-12-04 20:35:09 UTC
Permalink
Bob, I remember from my K&R Unix book that ls can be used in scripts.
In fact that is why
$ ls
acts different than
$ ls | cat

Plus there are lots of things ls can do that find cannot.

For instance sorting.

How are you going to do
$ ls -t
with find?
積丹尼 Dan Jacobson
2018-12-04 21:11:02 UTC
Permalink
(Probably The Unix Programming Environment by K & P.)
積丹尼 Dan Jacobson
2018-12-04 21:12:01 UTC
Permalink
Don't let that ls colors stuff fool you. It originally didn't have that.
積丹尼 Dan Jacobson
2018-12-04 21:13:26 UTC
Permalink
Are you saying you want to enhance find(1) to sort its output?

Loading...