Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk syntax in bash

Status
Not open for further replies.

lseboek1

Technical User
Nov 20, 2002
6
CH
Hi,

I have a small awk code which works in ksh, but doesn't work bash:

ksh:
$ echo $PATH|awk {' print index("abca","b"); '}
2
bash:
bash-2.03$ echo $PATH|awk {' print index("abca","b"); '}
awk: syntax error near line 1
awk: bailing out near line 1

In both shell I've used the same awk version.

I've tested it with other awk functions. When there is a "," in the awk command it fails always in bash. When I use a function with one parameter it works. (e.g exp,int).

Does somebody know which syntax should I use to be able to use functions with more parameters in bash?
thanks & rgrds
lseboek
 
From:
echo $PATH|awk {' print index("abca","b"); '}

To:
echo $PATH | awk ' {print index("abca","b")}'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top