I need help in unix scripting.
I am trying to use the head
command in unix script but it's showing some errors.
for file_name in $(cat files.lst);
do
echo $file_name
file_count=$(head -n1 ${file_name} | awk -F '|' '{print NF}')
echo `pwd`/${file_name}
echo $file_count
done
I am trying to get the file name from the files list and get the column count for each file, but it's showing the file is not present.
The file, the script and the list file are all in the same directory.
I tried head -n1 ${file_name}
, head -n1 $file_name
in the script but did not get the result.
Can anyone please let me know if my logic is right and what is the mistake?