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
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter