| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
|
| hi, i am trying to reflect the name (example: LDRIVE in to RDRIVE) in UNIX sun environment and please find below the script i used. awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1), "[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and (match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = %s (unchanged)\n", length(substr($2,2)), NR, substr($2,2); else if (substr($2,2,1) == "R") printf "(VNAME 1 %d, %6d ) = L%s (was %s)\n", length(substr($2,2)), NR, substr($2,3), substr($2,2); else if (substr($2,2,1) == "L") printf "(VNAME 1 %d, %6d ) = R%s (was %s)\n", length(substr($2,2)), NR, substr($2,3), substr($2,2); else if ( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R") printf "(VNAME 1 %d, %6d ) = %sL%s (was %s)\n", length(substr($2,2)), NR, substr($2,2,1), substr($2,4), substr($2,2); else if (substr($2,3,1) == "L") printf "(VNAME 1 %d, %6d ) = %sR%s (was %s) \n", length(substr($2,2)), NR, substr($2,2,1), substr($2,4), substr($2,2)}' gridnames awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1), "[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and (match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = %s \n", length(substr($2,2)), NR, substr($2,2); else if (substr($2,2,1) == "R") printf "(VNAME 1 %d, %6d ) = L%s\n", length(substr($2,2)), NR, substr($2,3); else if (substr($2,2,1) == "L") printf "(VNAME 1 %d, %6d ) = R%s\n", length(substr($2,2)), NR, substr($2,3); else if ( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R") printf "(VNAME 1 %d, %6d ) = %sL%s\n", length(substr($2,2)), NR, substr($2,2,1), substr($2,4); else if (substr($2,3,1) == "L") printf "(VNAME 1 %d, %6d ) = %sR%s\n", length(substr($2,2)), NR, substr($2,2,1), substr($2,4)}' gridnames >> piok.in2 the following error is coming when i execute: awk: syntax error near line 1 awk: bailing out near line 1 awk: syntax error near line 1 awk: bailing out near line 1 can any one help in shorting out thanks ravi |
|
#2
|
| ramkumar2yk-at-gmail.com wrote: > hi, > > i am trying to reflect the name (example: LDRIVE in to RDRIVE) in UNIX > sun environment and please find below the script i used. > > awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1), > "[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and > (match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = > %s (unchanged)\n", length(substr($2,2)), NR, substr($2,2); else if > (substr($2,2,1) == "R") printf "(VNAME 1 %d, %6d ) = L%s (was %s)\n", > length(substr($2,2)), NR, substr($2,3), substr($2,2); else if > (substr($2,2,1) == "L") printf "(VNAME 1 %d, %6d ) = R%s (was %s)\n", > length(substr($2,2)), NR, substr($2,3), substr($2,2); else if > ( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R") > printf "(VNAME 1 %d, %6d ) = %sL%s (was %s)\n", length(substr($2,2)), > NR, substr($2,2,1), substr($2,4), substr($2,2); else if > (substr($2,3,1) == "L") printf "(VNAME 1 %d, %6d ) = %sR%s (was %s) > \n", length(substr($2,2)), NR, substr($2,2,1), substr($2,4), > substr($2,2)}' gridnames > > > awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1), > "[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and > (match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = %s > \n", length(substr($2,2)), NR, substr($2,2); else if (substr($2,2,1) > == "R") printf "(VNAME 1 %d, %6d ) = L%s\n", length(substr($2,2)), NR, > substr($2,3); else if (substr($2,2,1) == "L") printf "(VNAME 1 %d, > %6d ) = R%s\n", length(substr($2,2)), NR, substr($2,3); else if > ( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R") > printf "(VNAME 1 %d, %6d ) = %sL%s\n", length(substr($2,2)), NR, > substr($2,2,1), substr($2,4); else if (substr($2,3,1) == "L") printf > "(VNAME 1 %d, %6d ) = %sR%s\n", length(substr($2,2)), NR, > substr($2,2,1), substr($2,4)}' gridnames >> piok.in2 > > the following error is coming when i execute: > > awk: syntax error near line 1 > awk: bailing out near line 1 > awk: syntax error near line 1 > awk: bailing out near line 1 > > can any one help in shorting out Just a note... It is possible to put awk programs in a file, say "trash.awk", and call it as... awk -f trash.awk datafiles Then you can also format your code (for free; no extra fee) to become readable by using a single command per line and proper indentation. Doing that will greatly increase the number of people who are willing to analyse your code. Having an awk program of many lines might also point you to the line number of your problem without necessity to ask here. Are you working on solaris? Try /usr/xpg4/bin/awk instead of /bin/awk. Janis > > thanks > > ravi |
|
#3
|
| On Wed, 27 Aug 2008 00:02:14 -0700 (PDT), ramkumar2yk-at-gmail.com wrote: >hi, > >i am trying to reflect the name (example: LDRIVE in to RDRIVE) in UNIX >sun environment and please find below the script i used. > >awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1), >"[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and >(match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = >%s (unchanged)\n", length(substr($2,2)), NR, substr($2,2); else if >(substr($2,2,1) == "R") printf "(VNAME 1 %d, %6d ) = L%s (was %s)\n", >length(substr($2,2)), NR, substr($2,3), substr($2,2); else if >(substr($2,2,1) == "L") printf "(VNAME 1 %d, %6d ) = R%s (was %s)\n", What ever happened to whitespace and structure? Grant. -- http://bugsplatter.id.au/ |
|
#4
|
| ramkumar2yk-at-gmail.com wrote: > hi, > > i am trying to reflect the name (example: LDRIVE in to RDRIVE) in UNIX > sun environment and please find below the script i used. > > awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1), > "[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and > (match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = > %s (unchanged)\n", length(substr($2,2)), NR, substr($2,2); else if > (substr($2,2,1) == "R") printf "(VNAME 1 %d, %6d ) = L%s (was %s)\n", > length(substr($2,2)), NR, substr($2,3), substr($2,2); else if > (substr($2,2,1) == "L") printf "(VNAME 1 %d, %6d ) = R%s (was %s)\n", > length(substr($2,2)), NR, substr($2,3), substr($2,2); else if > ( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R") > printf "(VNAME 1 %d, %6d ) = %sL%s (was %s)\n", length(substr($2,2)), > NR, substr($2,2,1), substr($2,4), substr($2,2); else if > (substr($2,3,1) == "L") printf "(VNAME 1 %d, %6d ) = %sR%s (was %s) > \n", length(substr($2,2)), NR, substr($2,2,1), substr($2,4), > substr($2,2)}' gridnames > > > awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1), > "[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and > (match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = %s > \n", length(substr($2,2)), NR, substr($2,2); else if (substr($2,2,1) > == "R") printf "(VNAME 1 %d, %6d ) = L%s\n", length(substr($2,2)), NR, > substr($2,3); else if (substr($2,2,1) == "L") printf "(VNAME 1 %d, > %6d ) = R%s\n", length(substr($2,2)), NR, substr($2,3); else if > ( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R") > printf "(VNAME 1 %d, %6d ) = %sL%s\n", length(substr($2,2)), NR, > substr($2,2,1), substr($2,4); else if (substr($2,3,1) == "L") printf > "(VNAME 1 %d, %6d ) = %sR%s\n", length(substr($2,2)), NR, > substr($2,2,1), substr($2,4)}' gridnames >> piok.in2 > > the following error is coming when i execute: > > awk: syntax error near line 1 > awk: bailing out near line 1 > awk: syntax error near line 1 > awk: bailing out near line 1 > > can any one help in shorting out > > thanks > > ravi Try nawk or /usr/xpg4/bin/awk rather than /bin/awk. At least you'll get a better error message. -- echo imhcea\.lophc.tcs.hmo | sed 's2\(....\)\(.\{5\}\)2\2\122;s1\(.\)\(.\)1\2\11g;1 s;\.;::;2' |
|
#5
|
| On Aug 27, 9:34*pm, Michael Tosch wrote: > ramkumar...@gmail.com wrote: > > hi, > > > i am trying to reflect the name (example: LDRIVE in to RDRIVE) in UNIX > > sun environment and please find below the script i used. > > > awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1), > > "[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and > > (match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = > > %s *(unchanged)\n", length(substr($2,2)), NR, substr($2,2); else if > > (substr($2,2,1) == "R") printf "(VNAME 1 %d, %6d ) = L%s *(was %s)\n", > > length(substr($2,2)), NR, substr($2,3), *substr($2,2); else if > > (substr($2,2,1) == "L") printf "(VNAME 1 %d, %6d ) = R%s *(was %s)\n", > > length(substr($2,2)), NR, substr($2,3), substr($2,2); else if > > ( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R") > > printf "(VNAME 1 %d, %6d ) = %sL%s *(was %s)\n", length(substr($2,2)), > > NR, substr($2,2,1), substr($2,4), *substr($2,2); else if > > (substr($2,3,1) == "L") printf "(VNAME 1 %d, %6d ) = %sR%s *(was %s) > > \n", length(substr($2,2)), NR, substr($2,2,1), substr($2,4), > > substr($2,2)}' gridnames > > > awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1), > > "[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and > > (match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = %s > > \n", length(substr($2,2)), NR, substr($2,2); else if (substr($2,2,1) > > == "R") printf "(VNAME 1 %d, %6d ) = L%s\n", length(substr($2,2)), NR, > > substr($2,3); else if (substr($2,2,1) == "L") printf "(VNAME 1 %d, > > %6d ) = R%s\n", length(substr($2,2)), NR, substr($2,3); else if > > ( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R") > > printf "(VNAME 1 %d, %6d ) = %sL%s\n", length(substr($2,2)), NR, > > substr($2,2,1), substr($2,4); else if (substr($2,3,1) == "L") printf > > "(VNAME 1 %d, %6d ) = %sR%s\n", length(substr($2,2)), NR, > > substr($2,2,1), substr($2,4)}' gridnames >> piok.in2 > > > the following error is coming when i execute: > > > awk: syntax error near line 1 > > awk: bailing out near line 1 > > awk: syntax error near line 1 > > awk: bailing out near line 1 > > > can any one help in shorting out > > > thanks > > > ravi > > Try nawk or /usr/xpg4/bin/awk rather than /bin/awk. > At least you'll get a better error message. > > -- > echo imhcea\.lophc.tcs.hmo | > sed 's2\(....\)\(.\{5\}\)2\2\122;s1\(.\)\(.\)1\2\11g;1 s;\.;::;2'- Hide quoted text - > > - Show quoted text - Hi, In addition to Janis'recommendations, you'd gain in readability if you were storing function results into intermediary variables. Anyway, I think the errors arise from the fact that "and" is not the right logical conjunction operator. You'd rather use "&&". Hope it helps. Cheers, Jean-Philippe |
|
#6
|
| On Aug 27, 7:19 am, Janis Papanagnou wrote: > ramkumar...@gmail.com wrote: > > hi, > > > i am trying to reflect the name (example: LDRIVE in to RDRIVE) in UNIX > > sun environment and please find below the script i used. > > > awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1), > > "[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and > > (match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = > > %s (unchanged)\n", length(substr($2,2)), NR, substr($2,2); else if > > (substr($2,2,1) == "R") printf "(VNAME 1 %d, %6d ) = L%s (was %s)\n", > > length(substr($2,2)), NR, substr($2,3), substr($2,2); else if > > (substr($2,2,1) == "L") printf "(VNAME 1 %d, %6d ) = R%s (was %s)\n", > > length(substr($2,2)), NR, substr($2,3), substr($2,2); else if > > ( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R") > > printf "(VNAME 1 %d, %6d ) = %sL%s (was %s)\n", length(substr($2,2)), > > NR, substr($2,2,1), substr($2,4), substr($2,2); else if > > (substr($2,3,1) == "L") printf "(VNAME 1 %d, %6d ) = %sR%s (was %s) > > \n", length(substr($2,2)), NR, substr($2,2,1), substr($2,4), > > substr($2,2)}' gridnames > > > awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1), > > "[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and > > (match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = %s > > \n", length(substr($2,2)), NR, substr($2,2); else if (substr($2,2,1) > > == "R") printf "(VNAME 1 %d, %6d ) = L%s\n", length(substr($2,2)), NR, > > substr($2,3); else if (substr($2,2,1) == "L") printf "(VNAME 1 %d, > > %6d ) = R%s\n", length(substr($2,2)), NR, substr($2,3); else if > > ( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R") > > printf "(VNAME 1 %d, %6d ) = %sL%s\n", length(substr($2,2)), NR, > > substr($2,2,1), substr($2,4); else if (substr($2,3,1) == "L") printf > > "(VNAME 1 %d, %6d ) = %sR%s\n", length(substr($2,2)), NR, > > substr($2,2,1), substr($2,4)}' gridnames >> piok.in2 > > > the following error is coming when i execute: > > > awk: syntax error near line 1 > > awk: bailing out near line 1 > > awk: syntax error near line 1 > > awk: bailing out near line 1 > > > can any one help in shorting out > > Just a note... > > It is possible to put awk programs in a file, say "trash.awk", and > call it as... > > awk -f trash.awk datafiles > > Then you can also format your code (for free; no extra fee) to become > readable by using a single command per line and proper indentation. > Doing that will greatly increase the number of people who are willing > to analyse your code. Having an awk program of many lines might also > point you to the line number of your problem without necessity to ask > here. > > Are you working on solaris? Try /usr/xpg4/bin/awk instead of /bin/awk. > > Janis > > > > > thanks > > > ravi Greetings and thanks for your effort. when i execute the above script in hp workstation it is working fine but in the sun machine it is not working. can you guide me to short out from the below error: awk: syntax error near line 1 awk: bailing out near line 1 awk: syntax error near line 1 awk: bailing out near line 1 thanks ravi |
|
#7
|
| ramkumar2yk-at-gmail.com wrote: > On Aug 27, 7:19 am, Janis Papanagnou > wrote: > >>ramkumar...@gmail.com wrote: >> >>>hi, >> >>>i am trying to reflect the name (example: LDRIVE in to RDRIVE) in UNIX >>>sun environment and please find below the script i used. >> >>>awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1), >>>"[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and >>>(match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = >>>%s (unchanged)\n", length(substr($2,2)), NR, substr($2,2); else if >>>(substr($2,2,1) == "R") printf "(VNAME 1 %d, %6d ) = L%s (was %s)\n", >>>length(substr($2,2)), NR, substr($2,3), substr($2,2); else if >>>(substr($2,2,1) == "L") printf "(VNAME 1 %d, %6d ) = R%s (was %s)\n", >>>length(substr($2,2)), NR, substr($2,3), substr($2,2); else if >>>( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R") >>>printf "(VNAME 1 %d, %6d ) = %sL%s (was %s)\n", length(substr($2,2)), >>>NR, substr($2,2,1), substr($2,4), substr($2,2); else if >>>(substr($2,3,1) == "L") printf "(VNAME 1 %d, %6d ) = %sR%s (was %s) >>>\n", length(substr($2,2)), NR, substr($2,2,1), substr($2,4), >>>substr($2,2)}' gridnames >> >>>awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1), >>>"[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and >>>(match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = %s >>>\n", length(substr($2,2)), NR, substr($2,2); else if (substr($2,2,1) >>>== "R") printf "(VNAME 1 %d, %6d ) = L%s\n", length(substr($2,2)), NR, >>>substr($2,3); else if (substr($2,2,1) == "L") printf "(VNAME 1 %d, >>>%6d ) = R%s\n", length(substr($2,2)), NR, substr($2,3); else if >>>( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R") >>>printf "(VNAME 1 %d, %6d ) = %sL%s\n", length(substr($2,2)), NR, >>>substr($2,2,1), substr($2,4); else if (substr($2,3,1) == "L") printf >>>"(VNAME 1 %d, %6d ) = %sR%s\n", length(substr($2,2)), NR, >>>substr($2,2,1), substr($2,4)}' gridnames >> piok.in2 >> >>>the following error is coming when i execute: >> >>>awk: syntax error near line 1 >>>awk: bailing out near line 1 >>>awk: syntax error near line 1 >>>awk: bailing out near line 1 >> >>>can any one help in shorting out >> >>Just a note... >> >>It is possible to put awk programs in a file, say "trash.awk", and >>call it as... >> >> awk -f trash.awk datafiles >> >>Then you can also format your code (for free; no extra fee) to become >>readable by using a single command per line and proper indentation. >>Doing that will greatly increase the number of people who are willing >>to analyse your code. Having an awk program of many lines might also >>point you to the line number of your problem without necessity to ask >>here. >> >>Are you working on solaris? Try /usr/xpg4/bin/awk instead of /bin/awk. >> >>Janis >> >> >> >> >>>thanks >> >>>ravi > > > > Greetings and thanks for your effort. > > when i execute the above script in hp workstation it is working fine > but in the sun machine it is not working. can you guide me to short > out from the below error: As said, instead of... awk -F ">" '...' try /usr/xpg4/bin/awk -F ">" '...' or reformat your code to make it legible for an analysis. Janis > > awk: syntax error near line 1 > awk: bailing out near line 1 > awk: syntax error near line 1 > awk: bailing out near line 1 > > thanks > > ravi |
|
#8
|
| ramkumar2yk-at-gmail.com writes: > Greetings and thanks for your effort. > > when i execute the above script in hp workstation it is working fine > but in the sun machine it is not working. can you guide me to short > out from the below error: > > awk: syntax error near line 1 > awk: bailing out near line 1 > awk: syntax error near line 1 > awk: bailing out near line 1 Don't use awk. Use nawk. This is new awk. Both ar on the SOlaris OS. There are many many reasons to use the new awk. Reason #1 - better error messages. |
|
#9
|
| On 9/1/2008 7:07 PM, Maxwell Lol wrote: > ramkumar2yk-at-gmail.com writes: > > >>Greetings and thanks for your effort. >> >>when i execute the above script in hp workstation it is working fine >>but in the sun machine it is not working. can you guide me to short >>out from the below error: >> >>awk: syntax error near line 1 >>awk: bailing out near line 1 >>awk: syntax error near line 1 >>awk: bailing out near line 1 > > > Don't use awk. Use nawk. This is new awk. Or /usr/xpg4/bin/awk. Just don't use old, broken awk. > Both ar on the SOlaris OS. > There are many many reasons to use the new awk. > Reason #1 - better error messages. Reason #1 - fewer error messages ;-). Ed. |
|
#10
|
| In article <48BD3213.9030908@lsupcaemnt.com>, Ed Morton >On 9/1/2008 7:07 PM, Maxwell Lol wrote: >> ramkumar2yk-at-gmail.com writes: >> >> >>>Greetings and thanks for your effort. >>> >>>when i execute the above script in hp workstation it is working fine >>>but in the sun machine it is not working. can you guide me to short >>>out from the below error: >>> >>>awk: syntax error near line 1 >>>awk: bailing out near line 1 >>>awk: syntax error near line 1 >>>awk: bailing out near line 1 >> >> >> Don't use awk. Use nawk. This is new awk. > >Or /usr/xpg4/bin/awk. Just don't use old, broken awk. Why do people give this crappy advice? Both nawk and xpg4awk are just somewhat better (read: not terrible) than Solaris:binawk. If you're going to go non-standard (don't bother to argue with this; you know what I mean), just get GAWK and be happy. >> Both ar on the SOlaris OS. >> There are many many reasons to use the new awk. >> Reason #1 - better error messages. > >Reason #1 - fewer error messages ;-). > > Ed. Yes. That should be: Reason #1 - fewer error messages Reason #2 - better error messages |
![]() |
| Thread Tools | |
| Display Modes | |