- If a parameter is provided as an input, script should only check number of lines for that input file, otherwise script should display number of lines for each file within that directory.
- The script file should be ignored i.e. the count for the script file should not be displayed.
I tried:
#!/bin/bash
if [ $# -eq 0 ]
then
for l in *.txt
do
echo $(wc -l $l)
done
else
for l in $*
do
echo $(wc -l $l)
done
fi
But I am not allowed to explicitly mention the file type i.e *.txt - it must check all files except script file.
echo $(), just callwcdirectly$0variable to skip the script itself.