Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Shell script to perform string replacement in a file and view the content of file

Posted By: Voliny Fischer     Category: Unix / Linux / Ubuntu     Views: 6409

Write a shell script to perform string replacement in a file and view the content of file.

Code for Shell script to perform string replacement in a file and view the content of file in Unix / Linux / Ubuntu

clear
c="y"while [ $c = "y" ]
do
echo "Enter any file name: "
read f1
if [ -f $f1 ]
then
    echo "Enter old string"
    read o
    echo "Enter new string to be replace:"
    read n
    replace $o $n <$f1
    echo $o" is replace by "$n
    echo "Do u want to view file? "
    read c
    if [ $c !="y" ] 
    then
        exit
    else
        cat $f1
    fi 
else
    echo "File not exist"
fi
done
  
Share: 



Voliny Fischer
Voliny Fischer author of Shell script to perform string replacement in a file and view the content of file is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 

Other Interesting Articles in Unix / Linux / Ubuntu:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!