Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to show the number of lines, words and characters of all configuration files in /etc/*conf (with command wc).

How can I modify the command (or commandline) to not view the error messages?

share|improve this question
1  
If Roy's answer below doesn't provide what you want, could you provide the command you're trying so we can get an idea of what's not working properly? –  Matrix Mole Mar 25 '10 at 22:46

4 Answers 4

up vote 5 down vote accepted
wc /etc/*conf 2>/dev/null
share|improve this answer

i don't have access to a shell right now, but you can try something like

cat /etc/*.conf 2> /dev/null | wc -l

That should redirect all the errors and leave the output to be passed to wc

share|improve this answer
    
this won't allow wc to output word/line/char counts per-file, if that's what the OP wants. it will get the total of all /etc/*conf files. –  quack quixote Mar 25 '10 at 23:30

Usually just redirect the standard output to /dev/null to ignore the output, but this is not good practice when writing shell scripts

Try use -q instead to run the shell in quite mode, which will produce less output.

This might not be relevant to the question, but just FYI.

share|improve this answer

!/bin/sh

look=`which find`
BACKUPLOCATION="/backup"
TODAYDIR=`date +%d-%b-%Y`
DELDIR=`date -d "-7 day" +%d-%b-%Y`

echo "Backup Deleting For Date : $DELDIR"
$LOOK $BACKUPLOCATION -type d -name $DELDIR -exec rm -rf {} \; 2>/dev/null
echo "Backup Deleted Successfully...!"
exit 0;

Above script is to delete backup folders created 7 days before. Run this script on daily basis in crontab. You can update the days by editing variable DELDIR, update -7 with any other number.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.