If you have done interactive commandline on the terminal and it works, you can write it also to the shell script. And vice versa. Interactive shell = read shell script from terminal = stdin. Shell script = read commandlines from file, not from stdin.
Thanks all..
I am having one more doubt..
Can I execute the awk file in a loop from ksh file.
For example
#!/bin/ksh
while read file
do
echo $file
echo "Total Number of Records in " $file ":"`wc -l $file |awk '{print $1}'`
awk -f Test.awk $file
done < filelist
where as filelist contains the list of input files..
I have tried this by giving list of 3 files in the filelist..But,It is not working. Please help
It is executing only the first file in the list
#!/bin/ksh
while read file
do
# echo result ok ?
echo "$file"
lines=$( wc -l < "$file" )
echo "Total Number of Records in $file: $lines"
# set variable filename and use it in your Test.awk or use builtin variable FILENAME
awk -v filename="$file" -f Test.awk "$file"
done < filelist