KSH for loop works on Solaris/Mac but not on Red Hat Linux -
the following ksh script gives me "no such file or directory" error message on red hat linux system. has solution?
#!/usr/bin/ksh f in `cat files.dat` wc $f done
for example, files.dat
has 3 lines of data , each line file in current directory script running from.
a.c a.h b.c
note, same loop generated same error message if running command line too.
it works on solaris/mac box not on red hat system.
thanks.
instead of for ... cat
, should use
while read -r f wc "$f" done < files.dat
and should use $()
instead of backticks when need command substitution.
but problem files a.c
, etc., not there, have different names, invisible characters in names, or line endings in files.dat
cr/lf (dos/windows-style) instead of \n
(lf - unix-style) or there odd characters in file otherwise.
Comments
Post a Comment