Tom's Hardware > Forum > Linux/Free BSD > Linux/Free BSD General Discussion > Scripting help: how to make ls shut up?

Scripting help: how to make ls shut up?

Forum Linux/Free BSD : Linux/Free BSD General Discussion - Scripting help: how to make ls shut up?

Tom's Hardware: Over 1.4 million members in 6 different countries available to answer all your high-tech questions. Sign up now! Its free!
Word :    Username :           
 

Hi, I have made a script that prints some various things to the screen. In the process the script is doing a loop which searches for certain files in certain directories. The problem comes in when it doesnt find any files. It prints an error to the screen. There must be a way to prevent that! Any help is appreciated.

<font color=blue>- Studies show that the human brain approaches 100 percent retention. -</font color=blue>

Sponsored Links
Register or log in to remove.

It's printing the error message to stderr, not stdout which is what you are capturing. You need to redirect stderr to somewhere other than the screen (eg, /dev/null, or stdout)

<i>Do I look like I care?</i>

Reply to poorboy

Thanks for the help, I got it working. For anyone that is interested, stderr is 2, so you can do something like this:
ls somefilename 2> errorlog.txt



<font color=blue>- Studies show that the human brain approaches 100 percent retention. -</font color=blue>

Reply to Thanatos00
Tom's Hardware > Forum > Linux/Free BSD > Linux/Free BSD General Discussion > Scripting help: how to make ls shut up?
Go to:

There are 794 identified and unidentified users. To see the list of identified users, Click here.

Please mind

You are about to answer a thread that has been inactive for more than 6 months.
If you still wish to proceed, please ensure that your posting is original and does not duplicate or overlap any prior responses to this thread.

Add a reply Cancel
Sponsored links
  • Ask the community now
  • Publish
Ad
They won a badge
Join us in greeting them