Search code examples
csh

C Shell "command not found" for standard tools using foreach path


I am trying to use the awk in my C shell script to split my string.

When I use awk outside a loop, the command works. For instance:

set var = *
set path = `echo ${var[1]} | awk '{split($0,a,"_"); print a[1]}'`

However, when I use the same command inside a loop the following error appears awk: command not found.

For instance:

set var = *

foreach path ( $var )
    echo $path | awk '{split($0,a,"_"); print a[1]}'
end

Solution

  • Use a variable name that's not $path, since this messes with Csh's program search path.