Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Develop a bash script which can accomplish the following tasks: -This program ha

ID: 3687645 • Letter: D

Question

Develop a bash script which can accomplish the following tasks: -This program has two arguments. The first one is a word, the second one is a path. -This program searches all files in the given path, and check whether the file name contains the given word. -If the file name contains the given word, output this file name to standard output (screen) and ask user whether need delete this file. -User can input "y" to delete this file and "n" to ignore this deletion -Use a loop to check all files given path. input, output example: ./part6.sh foo . .foo.txt Do you want to remove this file? [y/n] y food.txt Do you want to remove this file? [y/n] n ...

Explanation / Answer

for entry in "$2"/*
do
echo "$entry"
if echo "$entry" | grep -q "$1";
then
printf $entry" Do you want to remove this file? [y/n] ";
read ans
if [ $ans == y ];
then
rm -f $entry
fi
fi
done