Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am attempting to pull RX packets, CPU vendor and model along with CPU MHz.

Here is my script:


case $1="-r"
COUNT='ifconfig eth0 | grep 'RX packets:' | cut -d: -f2 | awk '{print $1}''
DATE='date +"%H:%M:%S"' echo "Time" $'\t' $'\t' "Total Packets eth0" echo $DATE $'\t' $'\t'$COUNT ;; "-c"
VENDOR='cat /proc/cpuinfo | grep 'vendor_id' | cut -d: -f2 | awk '{print $1}''
MODEL='cat /proc/cpuinfo |grep 'model name' | cut -d: -f2' CPU='more /proc/cpuinfo | grep 'cpu MHz' | cut -d:$

*) echo

;; esac

I am getting the following error:

./systemstat: line 6: syntax error near unexpected token `COUNT='ifconfig eth0 | grep 'RX'
./systemstat: line 6: `COUNT='ifconfig eth0 | grep 'RX packets:' | cut -d: -f2 | awk '{print $1}'' '

Can anyone assist?

Thank you!

share|improve this question
up vote 3 down vote accepted

Sincerely, your script is a mess. Before to start with bash scripting, you should read first something like: Bash Guide for Beginners.

Now, your script should look like:


case $1 in
    COUNT=`ifconfig eth0 | grep 'RX packets:' | cut -d: -f2 | awk '{print $1}'`
    DATE=`date +"%H:%M:%S"`
    echo -e "Time\t\tTotal Packets eth0" 
    echo -e "$DATE\t\t$COUNT"
    VENDOR=`cat /proc/cpuinfo | grep 'vendor_id' | cut -d: -f2 | awk 'NR==1'`
    MODEL=`cat /proc/cpuinfo | grep 'model name' | cut -d: -f2 | awk 'NR==1'` 
    MHZ=`more /proc/cpuinfo | grep 'cpu MHz' | cut -d: -f2 | awk 'NR==1'`
    echo -e "CPU Model:\n $MODEL" 
    echo -e "Vendor:\n $VENDOR" 
    echo -e "MHZ:\n $MHZ" 

    echo -e "Usage: `basename $0` OPTION\n\tOPTIONS:\n\t\t-r -> some explanation\n\t\t-c -> some explanation"

See also: Using case statements.

share|improve this answer

Your Answer


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.