3rd linux

PHOTO EMBED

Wed Nov 29 2023 07:45:50 GMT+0000 (Coordinated Universal Time)

Saved by @viinod07

Write a shell script that deletes all lines containing a specified word in one or more files 
supplied as arguments to it.
Script:
if [ $# -eq 0 ]
then
echo "Please enter one or more filenames as argument"
exit
fi
echo "Enter the word to be searched in files"
read word
echo “After deleting the specified word:”
for file in $*
do
sed "/$word/d" $file | tee tmp
mv tmp $file
done
Output:
sh delete.sh f1
Enter the word to be searched in files
Hi
After deleting the specified word:
This is LINUX & SHELL PROGRAMMING Lab
content_copyCOPY