Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 08-18-2006, 05:04 PM   #1
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


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:
  # 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......
Old 08-18-2006, 05:22 PM   #2
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 124Reputation: 124
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
LQ Newbie
Registered: Jun 2005
Location: Roosendaal
Distribution: Kubuntu 6.10, amd64
Posts: 13

Original Poster
Rep: Reputation: 0
Thanks for your quick 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 > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:06 PM.

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