Piping on Linux Command line

simonthecat

Member
Messages
60
Reaction score
0
Points
6
I was playing with piping in linux and came up with this:
Code:
echo $PATH | tr ;  “ “

Now I want to pass that to the ls -l command so I tried this:
Code:
echo $PATH | tr ;  “ “ | ls -l

But that just lists the current working directory.

Any ideas on why this did not work?
 
Last edited:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Alternatively,
Code:
echo $PATH | tr : ' ' | xargs ls -l
or, more appropriately,
Code:
echo $PATH | sed -E -e 's/\s/\\&/' -e 's/:/ /' | xargs ls -l
in case there are spaces in any of the paths.
 
Last edited:
Top