13

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?

quack quixote
  • 42,186
  • 14
  • 105
  • 129
pedro
  • 153
  • 1
  • 1
  • 5
  • 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? – Jonathan Heady Mar 25 '10 at 22:46

3 Answers3

26
wc /etc/*conf 2>/dev/null
Dennis Williamson
  • 106,229
  • 19
  • 167
  • 187
4

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

Roy Rico
  • 5,868
  • 7
  • 44
  • 57
  • 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
0

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.

imcoddy
  • 271
  • 1
  • 2
  • 5