Re: C shell script and awk.

From: rakesh sharma (sharma__r_at_hotmail.com)
Date: 05/24/04


Date: 24 May 2004 03:05:40 -0700

hsphuah@usa.com (Hon Seng Phuah) wrote in message news:

>
> I have wrote these statements and named as loginfo.csh:
>
> #! /bin/csh
>
> set filePath = $argv[1]
> set filePath = `echo $filePath | awk '{ split($filePath, subdir, "/");
> for (path
> in subdir) print path}'`
>
> echo $filePath
>
>
> When I ran above code using this command, "loginfo.csh
> /test/good/life", I got these errors:
>
> awk: Field $() is not correct.
> The input line number is 1.
> The source line number is 1.
>
> Anyone knows where my problem is?
>

$filePath is a shell variable and not an awk variable!
Also, since you programming in c-shell you have to mind
your backslashes:

#!/bin/csh -f
awk -v filePath="$argv[1]" \
BEGIN{ \
split(filePath,subdir,"/"); \
for(path in subdir) print path; \
}'