Sponsored Content
Top Forums Shell Programming and Scripting AWK syntax /bailing script error when executing in UNIX Post 302501396 by nandugo1 on Thursday 3rd of March 2011 12:01:53 PM
Old 03-03-2011
not working

well!!! the same code I have been using since long time...and it never showed this error....I am executing this on diff flavour of unix.....let me know any other way

---------- Post updated at 12:01 PM ---------- Previous update was at 11:58 AM ----------

Quote:
Originally Posted by Corona688
You get a useless use of cat award. Smilie

You also need to quote things more, probably $i is being split into two strings and awk is trying to use the second half of it as its script.

Code:
while read TOKEN
do
        grep -i -l "$i" *.sas | awk -v token="$i" '{print token "\t" $0}'
done < search



cat > abc
for i in `cat tks`
do
grep -i -l $i *.txt | awk -v token=$i '{print token "\t" $0}'
done

Control-D

cat > tks
India Australia America

Control-D

cat -> file1.txt

India and Australia are world champions in cricket

Control-D

cat -> file2.txt

America is NBA champion.

Control-D
Now all files created
at the unix prompt where you run all these files

sh abc
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

-awk: bailing out near line 1

Hi I'm using cygwin and the script below works just fine under cygwin.. when i upload it on a unix server the script fails with the following errors -awk: syntax error near line 1 -awk: bailing out near line 1 any ideas why? thanx awk '($2 ~ /*/) { if ($4 < 40){ print... (3 Replies)
Discussion started by: kion
3 Replies

2. 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

3. 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

4. Shell Programming and Scripting

How to Check Shell script syntax w/o executing

Hello All, I looking for a way to verify the correction of shell script syntax. Is there any switch like -c in perl which do this in shell ? Thank You. (1 Reply)
Discussion started by: Alalush
1 Replies

5. Shell Programming and Scripting

Awk and read bailing out

Hi All, Can some body help me in this to work #!/bin/ksh nof=`wc -l outFile_R.out | sed -e 's/*//g' ` no_of_lines=`expr $nof - 0` z=1 while ] do cat outFile_R.out | awk -v I="$z" 'NR==I { print $0 }' | read from_date to_date id echo "executing $from_date... (2 Replies)
Discussion started by: sol_nov
2 Replies

6. Answers to Frequently Asked Questions

awk: bailing out

If you see this: awk: syntax error near line 1 awk: bailing out near line 1 Chances are you are working on Solaris and you are using standard awk. If so, you need to use /usr/xpg4/bin/awk instead, which is POSIX awk (or nawk if that is not available). (1 Reply)
Discussion started by: Scrutinizer
1 Replies

7. Shell Programming and Scripting

Syntax Error in Unix Shell Script

I am trying to run a unix script in my home directory.Snippet below echo "`date '+%Y%m%d_%H%M%S'` Getting ProductList.dat" if ( -f $DIR/ProductList.dat) then cp $DIR/ProductList.dat MigratedProductList.dat else echo "`date '+%Y%m%d_%H%M%S'`ProductList.dat does not exist; Processing... (4 Replies)
Discussion started by: Mary James
4 Replies

8. Shell Programming and Scripting

Help with awk script (syntax error in regular expression)

I've found this script which seems very promising to solve my issue: To search and replace many different database passwords in many different (.php, .pl, .cgi, etc.) files across my filesystem. The passwords may or may not be contained within quotes, single quotes, etc. #!/bin/bash... (4 Replies)
Discussion started by: spacegoose
4 Replies

9. Shell Programming and Scripting

Isql syntax error in UNIX script

Hello Everyone, Coming again for your help to solve the below error: In a script, i had created a temp table (Temp_table) and loaded the data in it using bcp command (performed successfully) and I wanted to move it to the preferred table (called Main_table) for further use. hence I have added... (1 Reply)
Discussion started by: Suresh
1 Replies

10. UNIX for Advanced & Expert Users

Isql and If Exist syntax error in UNIX script

Hello Everyone, Coming again for your help to solve the below error: In a script, i had created a temp table (Temp_table) and loaded the data in it using bcp command (performed successfully) and I wanted to move it to the preferred table (called Main_table) for further use. hence I have added... (7 Replies)
Discussion started by: Suresh
7 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 01:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy