Results 1 to 6 of 6
Hi,
I haven't found an answer to this in the ls MAN page.
Is there a way to not output the result of ls when the result is no such ...
- 05-29-2009 #1Just Joined!
- Join Date
- May 2009
- Posts
- 72
Hide ls output when no such file or directory
Hi,
I haven't found an answer to this in the ls MAN page.
Is there a way to not output the result of ls when the result is no such file or directory?; to only display the output when actual files are found?
Thank you.
olacelle
- 05-29-2009 #2
Tab key is the solution
If you are having trouble in typing the name of the file exactly as it is, you can use the TAB key after typing the initials . LS command is configured to work that way i.e it displays an error when the file or folder is not present.
Only if I could understand the man pages
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu
- 05-29-2009 #3
Redirecting the standard error is the way. Like this:
If you want to make it persistent add alias to your .bashrc file in your home directory as:Code:ls testme 2> /dev/null
then run ~/.bashrc so that these changes take effect asCode:echo "alias ls='ls 2> /dev/null' " >> ~/.bashrc
The above line is a . (period) followed by a SPACE and then ~/.bashrc. Then if you want to test it, runCode:. ~/.bashrc
Code:ls meow
A candle looses nothing by lighting other candles. - Khalil Zibran.
Registered Linux User #490076
- 05-29-2009 #4
Perfect solution
Perfect solution I regret why it didn't come in my mind. Keep it up saivin
Only if I could understand the man pages
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu
- 05-29-2009 #5Just Joined!
- Join Date
- May 2009
- Posts
- 72
I didn't know about the '2>' that's perfect for me!
Thanks to both of you for your replies.
olacelle
- 05-29-2009 #6
2> is the error redirector
When ever you execute a command it either ends up as in success or in error . When error occurs you get the error on standard output i.e you monitor . In the case of LS command with wrong input the error was getting displayed on the screen, using the '2>' we have redirected the error to something that graceously takes care of it and doesn't display it on the monitor( STDoutput).
Only if I could understand the man pages
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu


Reply With Quote
