0

we have script that print all bad wsp files

 ./print_bad_wsp_files.sh



./aaaa/rrr/aaaa/fff/ooo/min.wsp
./aaaa/rrr/aaaa/fff/ooo/p50.wsp
./aaaa/rrr/aaaa/fff/ooo/min.wsp
./aaaa/rrr/aaaa/fff/ooo/p50.wsp

# ls -ltr

drwxr-xr-x  5 root root   36 Aug 14 14:58 aaaa

is it possible to pipe the script so I will get the ls -ltr results ? of each file?

I did that until now

 ./print_bad_wsp_files.sh | ls -ltr 

but it give only

 drwxr-xr-x  5 root root   36 Aug 14 14:58 aaaa

while the expected results should be

 -rw-r--r-- 1 graphite mo 17308 Oct 11  2017 ./aaaa/rrr/aaaa/fff/ooo/min.wsp
 -rw-r--r-- 1 graphite mo 13508 Oct 11  2017 ./aaaa/rrr/aaaa/fff/ooo/p50.wsp
 -rw-r--r-- 1 graphite mo 27208 Oct 11  2017 ./aaaa/rrr/aaaa/fff/ooo/min.wsp
 -rw-r--r-- 1 graphite mo 19208 Oct 11  2017 ./aaaa/rrr/aaaa/fff/ooo/p50.wsp
1
  • the output is "one filename per line"?
    – Jeff Schaller
    Aug 14, 2018 at 16:34

1 Answer 1

1

All you may need here is xargs:

./print_bad_wsp_files.sh | xargs ls -ltr

xargs will read the output from the script and execute ls -ltr on all of them (potentially grouped in bunches, as many as will fit in each call to ls).

Note that if there are multiple calls to ls, each ls will sort its own list of files (by reverse time) separately.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .