CShell Syntax Problem

Hi guys,

Basically I'm trying to write a CShell script that calls an awk script on a given directory (given in command-line). I keep getting a syntax error with my code though:

#!/bin/csh
set dir = $ARGV[1]
foreach file ( $dir/* )
    set output = 'awk -f /Desktop/aal $file'
    echo $output
end

Anyone see what I'm doing wrong?

Thanks!

You might want to read those:
Csh Programming Considered Harmful
Top Ten Reasons not to use the C shell

Also, if you're just echoing the awk output, you can get that much quicker:

#!/bin/ksh
awk -f /Desktop/aal $dir/*

Same algorithm as your script in bash/ksh, where it's working:

#!/bin/ksh
dir="$1"
for file in "$dir/*"
do
    output=$( awk -f /Desktop/aal "$file" )
    echo $output
done

Thanks a lot for the useful reply but I have to use the C-Shell as it's a piece of coursework. Any other suggestions?

Just 2:

  1. post home- and coursework in the appropriate forum.
  2. show your prof the 2 links I've posted above