awk syntax error


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers awk syntax error
# 1  
Old 03-17-2008
awk syntax error

I generate a fullpath variable two different ways:

1) concat two variables rootpath and relpath to give me fullpath

2) use 'find' to get the fullpath

when I echo the variable, I get the same output for both. However,
I print the variable from method 1 in the below loop I get "awk syntax error near line 1" The second method works fine



while read line
do
if test $i -ge 1;
then
echo "$line" | awk -F'|' '{print "cd" " '$fullpath'/" }' >> RemoveFiles.sh
echo "$line" | awk -F'|' '{print "rm \""$1 "\"" }' >> RemoveFiles.sh


fi

i=$i+1
done < $input


contents of fullpath:
/supmm/su/gsa44/svr/locs/workloc

From echo there are no differences between the two variables

Can anyone explain why method 1 does not work but method 2 does?


thanks,
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Syntax error in awk

I know the below code worked, but the syntax appears to be wrong and I can not seem to correct it. Thank you :). awk 'FNR==NR {E; next }>$3 in E {print $3, $5}' medical_exome__genes.txt RefSeqGene.txt > update.txt awk: cmd. line:1: FNR==NR {E; next }>$3 in E {print $3, $5} awk: cmd.... (2 Replies)
Discussion started by: cmccabe
2 Replies

2. Shell Programming and Scripting

awk if else syntax error

Could somebody gently point out the error of my ways in the below (the flu I'm fighting might be contributing to my current haplessness) awk -F="\t" \ '{ for (i = 1; i <= NR; i++); FNR == i; { if (length($3) < 56 && length($1) > 56) $1=($1" "$2); $2=$3; $3=$4; ... (1 Reply)
Discussion started by: Andrew767
1 Replies

3. Shell Programming and Scripting

awk syntax error

Can anyone work out why this line has a syntax error? awk '{if ($1==1) print NR,$0 } '${PROJECT}/${data_dir}/${ofolder}/STDEV/otimes_${per}_secs.dat > tmp2.txt I've check that the file exists in the given location (1 Reply)
Discussion started by: claire.a
1 Replies

4. Shell Programming and Scripting

awk syntax error

Hi All, I wrote a simple script.sh program for i in seq (22) do awk '$1==${i}' file1.txt|awk '{print $2}'> file${i}_study.txt done and then run it %bash %chmod +x script.sh % ./script.sh Give me error awk: $1==${i} awk: ^ syntax error Do you have any idea why... (3 Replies)
Discussion started by: senayasma
3 Replies

5. Shell Programming and Scripting

awk syntax error

Hi, I can't see what is wrong with the following command. I am extracting a dollar amount (AMT_REJ, 6th field) from a comma delimited record and need to output it as numeric, removing the $sign and decimal point and output to another file. Everything seems to work except the $ sign which I need... (1 Reply)
Discussion started by: ski
1 Replies

6. UNIX for Dummies Questions & Answers

awk Shell Script error : "Syntax Error : `Split' unexpected

hi there i write one awk script file in shell programing the code is related to dd/mm/yy to month, day year format but i get an error please can anybody help me out in this problem ?????? i give my code here including error awk ` # date-month -- convert mm/dd/yy to month day,... (2 Replies)
Discussion started by: Herry
2 Replies

7. UNIX for Dummies Questions & Answers

'awk' syntax error

Due to some syntax error, my below code is not working. #!/usr/bin/ksh nawk ' BEGIN { cur_val=0; cur_zero=0; cur_nine=0; sum_zero=0; sum_nine=0; } /^/ { cur_val=substr($0,5,2); if("cur_val" == "0") { ... (3 Replies)
Discussion started by: lokiman
3 Replies

8. Shell Programming and Scripting

syntax error with awk.

A shell script a.sh calls an awk script using : awk -v OUTPUTDIR=${OUTPUTDIR}${OUTPUTDIRDATE} -f ${SCRIPTSPATH}chngNullBillId.awk ${INPUTFILE} chngNullBillId.awk : { if (substr($0,9,4)=="0000") printf( "%s0001%s", substr($0,1,8), substr($0,13,67) )>>${OUTPUTDIR}"goodfile.txt"; else print... (2 Replies)
Discussion started by: Amruta Pitkar
2 Replies

9. Shell Programming and Scripting

awk syntax error

mVar=0 count=`awk -F, '( ( $2 ~ /^GIVEUP$/ && $3 ~ /^NEW$/ ) || ( $2 ~ /^SPLIT$/ && $3 ~ /^NEW$/ ) || ( $2 ~ /^OPTION$/ && $3 ~ /^NEW$/ ) || ( $2 ~ /^OPTIONSPLIT$/ && $3 ~ /^NEW$/ ) ) { count++ } END { print count }' myCSV.csv myVar=`expr $myVar + $count` Can I do this? I get a syntax... (4 Replies)
Discussion started by: yongho
4 Replies

10. UNIX for Dummies Questions & Answers

awk syntax error

can anyone see the awk syntax error near line 1? I keep getting this error and I'm not familiar with awk very well yet so it is hard for me to see the errors. fyi: deleteuser* refers to files in the directory where each one ends with a different date ls -1 /mfupload/prod02/ftp/deleteuser* |... (12 Replies)
Discussion started by: k@ssidy
12 Replies
Login or Register to Ask a Question
PERLQNX(1)						 Perl Programmers Reference Guide						PERLQNX(1)

NAME
perlqnx - Perl version 5 on QNX DESCRIPTION
As of perl5.7.2 all tests pass under: QNX 4.24G Watcom 10.6 with Beta/970211.wcc.update.tar.F socket3r.lib Nov21 1996. As of perl5.8.1 there is at least one test still failing. Some tests may complain under known circumstances. See below and hints/qnx.sh for more information. Under QNX 6.2.0 there are still a few tests which fail. See below and hints/qnx.sh for more information. Required Software for Compiling Perl on QNX4 As with many unix ports, this one depends on a few "standard" unix utilities which are not necessarily standard for QNX4. /bin/sh This is used heavily by Configure and then by perl itself. QNX4's version is fine, but Configure will choke on the 16-bit version, so if you are running QNX 4.22, link /bin/sh to /bin32/ksh ar This is the standard unix library builder. We use wlib. With Watcom 10.6, when wlib is linked as "ar", it behaves like ar and all is fine. Under 9.5, a cover is required. One is included in ../qnx nm This is used (optionally) by configure to list the contents of libraries. I will generate a cover function on the fly in the UU directory. cpp Configure and perl need a way to invoke a C preprocessor. I have created a simple cover for cc which does the right thing. Without this, Configure will create its own wrapper which works, but it doesn't handle some of the command line arguments that perl will throw at it. make You really need GNU make to compile this. GNU make ships by default with QNX 4.23, but you can get it from quics for earlier versions. Outstanding Issues with Perl on QNX4 There is no support for dynamically linked libraries in QNX4. If you wish to compile with the Socket extension, you need to have the TCP/IP toolkit, and you need to make sure that -lsocket locates the correct copy of socket3r.lib. Beware that the Watcom compiler ships with a stub version of socket3r.lib which has very little functionality. Also beware the order in which wlink searches directories for libraries. You may have /usr/lib/socket3r.lib pointing to the correct library, but wlink may pick up /usr/watcom/10.6/usr/lib/socket3r.lib instead. Make sure they both point to the correct library, that is, /usr/tcptk/current/usr/lib/socket3r.lib. The following tests may report errors under QNX4: dist/Cwd/Cwd.t will complain if `pwd` and cwd don't give the same results. cwd calls `fullpath -t`, so if you cd `fullpath -t` before running the test, it will pass. lib/File/Find/taint.t will complain if '.' is in your PATH. The PATH test is triggered because cwd calls `fullpath -t`. ext/IO/lib/IO/t/io_sock.t: Subtests 14 and 22 are skipped due to the fact that the functionality to read back the non-blocking status of a socket is not implemented in QNX's TCP/IP. This has been reported to QNX and it may work with later versions of TCP/IP. t/io/tell.t: Subtest 27 is failing. We are still investigating. QNX auxiliary files The files in the "qnx" directory are: qnx/ar A script that emulates the standard unix archive (aka library) utility. Under Watcom 10.6, ar is linked to wlib and provides the expected interface. With Watcom 9.5, a cover function is required. This one is fairly crude but has proved adequate for compiling perl. qnx/cpp A script that provides C preprocessing functionality. Configure can generate a similar cover, but it doesn't handle all the command- line options that perl throws at it. This might be reasonably placed in /usr/local/bin. Outstanding issues with perl under QNX6 The following tests are still failing for Perl 5.8.1 under QNX 6.2.0: op/sprintf.........................FAILED at test 91 lib/Benchmark......................FAILED at test 26 This is due to a bug in the C library's printf routine. printf("'%e'", 0. ) produces '0.000000e+0', but ANSI requires '0.000000e+00'. QNX has acknowledged the bug. AUTHOR
Norton T. Allen (allen@huarp.harvard.edu) perl v5.18.2 2013-11-04 PERLQNX(1)