511@ubuntu:~/Unix$ cat pass
hellounix
file1
#!/usr/bin
echo "Enter File Name"
read file
if [ -f $file ]
then
echo "File Found with a Name $file\n"
echo "File Content as below\n"
count=0
val=0
while read line
do
val=$("$line" | wc -c)
echo "$line -->Containd $val Charecter"
count=$((count+1))
done < $file
echo "Total Line in File : $count"
else
echo "File Not Found check other file using running script"
fi
Output :
511@ubuntu:~/Unix$ sh digitmismatch.sh
Enter File Name
pass
File Found with a Name pass
File Content as below
digitmismatch.sh: 1: digitmismatch.sh: hellounix: **not found**
hellounix -->Containd 0 Charecter
digitmismatch.sh: 1: digitmismatch.sh: file1: **not found**
file1 -->Containd 0 Charecter
Total Line in File : 2
==============================================================
Why the value of wc -c is not assigned to the variable val?
/usr/binis not a valid interpreter. Try#!/bin/bash