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"


Thread Tools Search this Thread Display Modes
Old Unix and Linux 03-09-2014   -   Original Discussion by vai_sh
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Join Date: Nov 2008
Last Activity: 19 March 2018, 12:05 AM EDT
Location: Amsterdam
Posts: 11,748
Thanks: 537
Thanked 3,413 Times in 3,008 Posts
A better approach would be to use a while read loop instead:

while read queue size
done < $configfile

Instead of

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

The Following User Says Thank You to Scrutinizer For This Useful Post:
vai_sh (03-09-2014)
Sponsored Links
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
Old Unix and Linux 03-10-2014   -   Original Discussion by vai_sh
MadeInGermany's Unix or Linux Image
MadeInGermany MadeInGermany is offline Forum Staff  
Join Date: May 2012
Last Activity: 20 March 2018, 11:40 PM EDT
Location: Simplicity
Posts: 4,008
Thanks: 343
Thanked 1,346 Times in 1,214 Posts
Another tip:

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

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

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 01:16 AM.