The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 12-09-2007
rodluo rodluo is offline
Registered User
  
 

Join Date: Dec 2007
Location: Hong Kong
Posts: 2
Quote:
Originally Posted by prowla View Post
So close...

Code:
SIZE=`grep sizelimit myfile | sed 's/^.*sizelimit //' | awk '{print $1}'`
should work (NB. It allows for the arguments to be in a different order in the file).
There are other options that involve parsing the line (either in awk or shell), like:

Code:
SIZE=0
grep sizelimit myfile | while read s
do
  set -- $s
  while [ $# -gt 0 ]
  do
    case $1 in
      -sizelimit) SIZE=$2; break;;
      *) shift;;
    esac
  done
done
Thanks a lot prowla!
The first option works fine. Did you mean it works even if "-sizelimit 80000000" is moved somewhere else in the line too?