Home /
Expert Answers /
Computer Science /
unix-programming-will-leave-thumbs-up-20-points-we-want-a-bash-script-which-will-take-a-lis-pa531
(Solved): UNIX PROGRAMMING. WILL LEAVE THUMBS UP :)
(20 points) We want a Bash script which will take a lis ...
UNIX PROGRAMMING. WILL LEAVE THUMBS UP :)
(20 points) We want a Bash script which will take a list of filenames on the command line and print out how many lines are in each file. For each of the following scripts, indicate whether it works. If it does not, show how to fix i by changing the fewest characters possible. (Note: output format is not important.) Script A Works as is. Needs fixing. \#! /bin/bash for file in $0 do wc -l file done Script B Works as is. ? Needs fixing. \#! /bin/bash for file in $? do echo -n "\$file " grep -c, , \$file done Script C Works as is. ? Needs fixing. \#! /bin/bash for file in * do echo -n "\$file " tr -dc ' \n ' < file | wc ?c done Script D Works as is. ? Needs fixing. #!/ bin/bash for file in $0 do echo -n "\$file " awk 'END \{ print NR \}' \$file done
Script A: Needs fixing.The variable file should be enclosed in double quotes ("$file") to handle filenames with spaces or special characters correctly.