Bash ls and command pipe Bash ls and command pipe unix unix

Bash ls and command pipe


You can't pipe stuff into ls.. You could do something like:

ls -ld $(cut -f 6 -d ':' /etc/passwd | sort -su)

By spawning a new bash to execute the cut | sort and passing it as a ls argument


ls does not take piped output. You could, however, use forward quotes to execute it on a list of directories:

ls `cut -f 6 -d ':' /etc/passwd | sort -su `


You could use xargs

cut -f 6 -d ':' /etc/passwd | sort -su | xargs ls