LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to suppress some of ls's output? (https://www.linuxquestions.org/questions/linux-general-1/how-to-suppress-some-of-lss-output-421343/)

BrianK 03-03-2006 02:50 PM

how to suppress some of ls's output?
 
if you do:

ls /usr /opt

it will display the output of each /usr and /opt, but it precedes each with "/usr:" and "/opt:"
Those entries foul up scripts that use something like "foreach f (`ls /usr /opt`)"

Is there a way to suppress the output of "/usr:" and "/opt:"?

Thanks

gilead 03-03-2006 03:05 PM

I couldn't find anything in the ls man page to do this. Do either of the following help?
Code:

ls /opt /usr | sed -e '/:/d' -e '/^$/d'
find /opt /usr -maxdepth 1 -print


BrianK 03-03-2006 03:16 PM

Quote:

Originally Posted by gilead
I couldn't find anything in the ls man page to do this. Do either of the following help?
Code:

ls /opt /usr | sed -e '/:/d' -e '/^$/d'
find /opt /usr -maxdepth 1 -print


I didn't find anything in the man pages either. The first method is a bit cumbersome, but the latter method works good - I hadn't thought of using find. ;)

still if there's a way to do it with just plain ol' ls, I'd be interested to know.


All times are GMT -5. The time now is 02:40 PM.