context is
{print > $1 >>> ".txt" <<<
awk: illegal statement at source line 1
I am getting the above error...
make sure you pay attention to sigle quote, double quote, brackets etc. It worked for me.
1 9992
1 9992
1 9993
1 9994
1 9994
$awk '{print > $1 ".txt"}' test.txt awk: syntax error at source line 1 context is {print > $1 >>> ".txt" <<<
awk: illegal statement at source line 1
This is what I get for my test.txt file
1 9992
1 9992
1 9993
1
here for a quick overview of the site Help Center Detailed answers to any questions you
Awk Bailing Out At Source Line 1
might have Meta Discuss the workings and policies of this site awk: illegal statement at source line 1 About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of http://seqanswers.com/forums/archive/index.php/t-27865.html 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up awk syntax error: syntax error at source line 1 up vote 1 down vote favorite The following is an example of some contents in an input file: username: thebestusernamethereis EMAILID: someemail@address.com enc_username: NULL MACHINE_CODE: NULL FIRSTNAME: http://stackoverflow.com/questions/34456328/awk-syntax-error-syntax-error-at-source-line-1 John LASTNAME: Doe ADDRESS1: NULL ADDRESS2: NULL COUNTRY: NULL CITY: NULL STATE: NULL ZCODE: NULL ACTIVATION_CODE: NULL ACCOUNT_STATUS: Y CREATION_DATE: 2010-07-02 12:02:33 DEFAULT_DRIVE: NULL EXCHANGE_BACKUP_ALLOWED: N SYSTEM_STATE_BACKUP_ALLOWED: N CHECKSUM_1_METHOD: NULL CHECKSUM_2_METHOD: NULL additional_flag_1: NULL additional_flag_2: NULL additional_flag_3: F USEDBY: F DATABASE_DRIVE: NULL maxquotalimit: 2147483648 CURQUOTALIMIT: 0 ECOMMERCE_FLAG: NULL phone: cancellation_date: NULL proxy_server: sb.domain.com proxy_port: 20000 proxy_port_server: 10001 num_accts: NULL license_cd: NULL IDRIVE_DEFAULT_DRIVE: NULL international_additional_flag_1: M move_identifier: NULL subscribe: N client_ip: NULL USEDBY_COUNT: 0 last_update_date: NULL promocode: NULL password_support: NULL UNDER MAINTENANCE: UNDEFINED I have an awk line that seems to causing the error in my script. So, I tested the line as follows: cat inputfile.txt | awk '$1 ~ /^(user_name:|EMAIL:|FIRST_NAME:|LAST_NAME:|CREATION_DATE:|REGISTRATION_STATUS:)$/{printf "%s,",$2\} $1 ~ /REGISTRATION_STATUS:/{print $2\}' inputfile.txt > outputfile.txt The error I receive is: awk: syntax error at source line 1 context is $1 ~ /^(user_name:|EMAIL:|FIRST_NAME:|LAST_NAME:|CREATION_DATE:|REGISTRATION_STATUS:)$/{printf >>> "%s,",$2\ <<< } $1 ~ /REGISTRATION_STATUS:/{print $2\} awk: illegal statement at source line 1 The strange thing about this error is that the scr
Support Search GitHub This repository Watch 488 Star 14,969 Fork 1,451 creationix/nvm Code Issues 106 Pull requests 20 Projects 0 Wiki Pulse Graphs https://github.com/creationix/nvm/issues/808 New issue awk: syntax error at source line 1 #808 Closed danielepolencic http://www.tek-tips.com/viewthread.cfm?qid=1748288 opened this Issue Aug 16, 2015 · 4 comments Projects None yet Labels bugs shell alias clobbering shell: zsh Milestone No milestone Assignees ljharb 3 participants danielepolencic commented Aug 16, 2015 I just checkout a fresh version of nvm from the repo (manual install). and every time I open syntax error the shell (zsh) I get the following error: Last login: Sun Aug 16 20:15:42 on ttys009 awk: syntax error at source line 1 context is { command >>> printf <<< ("%d%06d%06d\n", $1,$2,$3); } awk: illegal statement at source line 1 awk: syntax error at source line 1 context is { command >>> printf <<< ("%d%06d%06d\n", $1,$2,$3); } awk: illegal statement at awk syntax error source line 1 awk: syntax error at source line 1 context is { command >>> printf <<< ("%d%06d%06d\n", $1,$2,$3); } awk: illegal statement at source line 1 awk: syntax error at source line 1 context is { command >>> printf <<< ("%d%06d%06d\n", $1,$2,$3); } awk: illegal statement at source line 1 I tracked it down and it seems connected to this: https://github.com/creationix/nvm/blob/master/nvm.sh#L320 Then I noticed I had to checkout the latest release. When I reverted to v0.26.0 and everything worked as normal. Not sure if this counts as a bug or not. Collaborator ljharb commented Aug 16, 2015 Thanks, while I typically recommend people stick with released versions, this is definitely a bug in unreleased code. The line here 58ffa40#diff-e1e8e036966ad5aaf7709712cd5d8ee3R320 adds command before printf - I do this in a few other places and haven't had any bug reports in zsh, nor do tests fail :-/ I'll look into it. ljharb added shell: zsh shell alias clobbering labels Aug 16, 2015 ljharb self-assigned this Aug 16, 2015 ljharb added a commit that closed this issue Aug 17, 2015 ljharb AWK Forum at Tek-Tips HomeForumsProgrammersLanguagesAWK Forum awk syntax error thread271-1748288 Forum Search FAQs Links MVPs awk syntax error awk syntax error yesornot (TechnicalUser) (OP) 15 Apr 15 08:40 hi expected is to print single 'obsolete' or single 'input error' text (when conditions are met), but for the first if condition print (in this example): 1 3 fields, a>10 2 3 fields, a>10 what is wrong with "exit" in code below? CODE --> err# echo "a b c\na b c"|awk -va=11 '{if (NF==3&&a>10) print NR,NF" fields, a>10"; else if (NF==2&&a<=10) print "obsolete"; else print "input error"}' 1 3 fields, a>10 2 3 fields, a>10 # echo "a b c\na b c"|awk -va=10 '{if (NF==3&&a>10) print NR,NF" fields, a>10"; else if (NF==2&&a<=10) print "obsolete"; else print "input error"}' input error input error # echo "a b c\na b c"|awk -va=10 '{if (NF==3&&a>10) print NR,NF" fields, a>10"; else if (NF==2&&a<=10) print "obsolete"; else print "input error";exit}' input error # echo "a b c\na b c"|awk -va=11 '{if (NF==3&&a