Sunday 10 August 2014

Write a shell script that delete all lines containing a specific word in one or more file supplied as argument to it.


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
for file in $*
do
sed "/$word/d" $file | tee tmp
mv tmp $file
done

12 comments:

Unknown said...

sed "/$word/d" $file | tee tmp
could u please explain this

Unknown said...

sed "/$word/d" $file | tee tmp
could u please explain this

Anonymous said...

yes i can explain

Anonymous said...

come to my home . . i can explain everything to you

Anonymous said...

This would be helpful : http://www.msccomputerscience.com/2015/04/write-shell-script-that-deletes-all.html

Unknown said...

Where is output

Unknown said...

output???????????????????????????????????????/

Anonymous said...

does not work for me

Unknown said...

Beia side hoe

Anonymous said...

Im Scientist Zorema of nielit ��

Rajdeep said...

bhagg bc

Unknown said...

Bhag bhsdk sala where is the output

Post a Comment

 
- |