LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 08-18-2006, 05:04 PM   #1
Rindert
LQ Newbie
 
Registered: Jun 2005
Location: Roosendaal
Distribution: Kubuntu 6.10, amd64
Posts: 13

Rep: Reputation: 0
Do not show ls error in bash script


Hello.

I've just started writing my own basg script so i;m kinda new to this all.
My script is going though some directories using a while loop.
In the llop i do an ls command but in some direcotries it gives back an error. That is just becuase there are no file matching the pattern (no files at all.

How can you supprees those errors? The errors mess up all my echo commands because i use echo -n some times.

This i a small example:
Code:
  # Make the dir list to go trough
  find -print0 | \
  xargs -0 file | \
  grep ' directory' | \
  cut -f 1 -d : | \
  cut -c 3- | \
  while read cat_dir ; do
    # Aanmaken van het profiel
    cat_profile=`ls -1 *001.jpg | rev | cut -c 8- | rev` 
    # morescript......
  done
 
Old 08-18-2006, 05:22 PM   #2
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
Try adding '2>/dev/null' on the end of offending commands. This redirects errors to /dev/null rather than output.
 
Old 08-18-2006, 05:28 PM   #3
Rindert
LQ Newbie
 
Registered: Jun 2005
Location: Roosendaal
Distribution: Kubuntu 6.10, amd64
Posts: 13

Original Poster
Rep: Reputation: 0
Thanks for your quick reply
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script error noir911 Programming 4 07-25-2006 03:58 AM
error when tying to run python script(bash error?) shanenin Programming 5 01-10-2006 10:01 AM
making select show its menu in a bash script? zidane_tribal Programming 6 05-02-2005 05:52 AM
bash script error near 'else' ? nutthick Linux - Newbie 5 01-23-2005 03:41 PM
bash script error corbis_demon Linux - Newbie 7 09-27-2004 10:41 AM


All times are GMT -5. The time now is 11:40 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration