Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Solaris bash script using grep giving error

Status
Not open for further replies.
Aug 14, 2008
38
US
Trying to run the following one liner in a bash script to check our mailq for big users. But I receive the error below when trying to run from a script instead of command line. Command line it works great. Anybody have a solution or alternative?

#!/usr/bin/bash
mailq|grep ^[A-F0-9]|cut -c 42-80|sort |uniq -c|sort -n|tail > /tmp/qResults


result:

checkQueue.sh: [A-F0-9]: not found
Usage: grep -hblcnsviw pattern file . . .
.#
 
Solution is put tick marks around the regular expression. Thanks to PHV for the solution

#!/usr/bin/bash
mailq|grep '^[A-F0-9]'|cut -c 42-80|sort |uniq -c|sort -n|tail > /tmp/qResults
 
Virtual star for virtual PHV!

The internet - allowing those who don't know what they're talking about to have their say.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top