Unix/Linux Go Back    


HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

HP-UX: Shell Script giving " 0^J30: Syntax error"

HP-UX


Closed    
 
Thread Tools Search this Thread Display Modes
    #15  
Old Unix and Linux 03-09-2014   -   Original Discussion by vai_sh
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is online now Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 18 June 2018, 2:38 PM EDT
Location: Amsterdam
Posts: 11,828
Thanks: 545
Thanked 3,454 Times in 3,044 Posts
A better approach would be to use a while read loop instead:


Code:
while read queue size
do
  ...
done < $configfile

Instead of


Code:
for queue in `cat ${configfile}|cut -d ' ' -f1`
do
  ...
  size=`cat ${configfile}|grep "$queue"|cut -d " " -f2`
  ...
done

The Following User Says Thank You to Scrutinizer For This Useful Post:
vai_sh (03-09-2014)
Sponsored Links
    #16  
Old Unix and Linux 03-09-2014   -   Original Discussion by vai_sh
vai_sh's Unix or Linux Image
vai_sh vai_sh is offline
Registered User
 
Join Date: Mar 2014
Last Activity: 6 January 2015, 1:57 PM EST
Posts: 11
Thanks: 8
Thanked 0 Times in 0 Posts
Thanks for suggestion on using 'WHILE' loop with 'READ'.
Will try to use this in the script.
Sponsored Links
    #17  
Old Unix and Linux 03-10-2014   -   Original Discussion by vai_sh
MadeInGermany's Unix or Linux Image
MadeInGermany MadeInGermany is offline Forum Staff  
Moderator
 
Join Date: May 2012
Last Activity: 18 June 2018, 11:49 AM EDT
Location: Simplicity
Posts: 4,118
Thanks: 357
Thanked 1,400 Times in 1,258 Posts
Another tip:


Code:
size=`awk '$1==q {print $2; exit}' q="$queue" ${configfile}`

compares exactly the first column, and returns after the first match, so is more robust than


Code:
size=`grep -w "$queue" ${configfile} | cut -d " " -f2`

In contrast to grep it does not use regular expressions e.g. "tellabs[78]100" won't match.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with FTP Script which is causing "syntax error: unexpected end of file" Error mahi_mayu069 Shell Programming and Scripting 1 04-25-2013 07:27 AM
ksh-script "arithmetic syntax error" comparing strings old_mike Shell Programming and Scripting 3 10-14-2009 10:40 AM
In ksh shell command - Print "-ABC" is giving error sagarjani Shell Programming and Scripting 2 10-08-2008 04:32 PM
awk Shell Script error : "Syntax Error : `Split' unexpected Herry UNIX for Dummies Questions & Answers 2 03-17-2008 11:16 AM



All times are GMT -4. The time now is 03:04 PM.