Say I have a file of filenames like this:
requests.log
responses.log
resources used.log
and I want to view all of those files. I'd be tempted to do:
$ vi `cat /tmp/list`
but that winds up opening the files "requests.log", "responses.log", "resources", and "used.log" which is not what I want.
I tried
$ cat /tmp/list | xargs -L 99 vi
but that results in the error message "Warning: input not from a terminal"
I've tried editing the file and quoting each of the individual lines, but that was no help either.
Is there a way to do this short of writing some sort of front-end script?
(IFS=$'\n'; vi $(cat list))
. But if the lines in the file have trailing spaces, as your selfanswer implies, this will retain those spaces and the open will fail, so do(IFS=$'\n'; vi $(sed 's/ *$//' list))
. On ancient shells you may needIFS='<actual newline here>'
which looks ugly but works. – dave_thompson_085 May 05 '21 at 06:05