remove and replace text in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting remove and replace text in a file
# 1  
Old 01-08-2009
remove and replace text in a file

Hello all,
How would I go to a particular line in a file and remove certain text from it and replace with something that I want it to be there.

like: file /etc/abc
now look for line HOME="/export/xyz" in /etc/abc
and then replace with HOME=/"export/xyz1"


thanks in advance guys.
# 2  
Old 01-08-2009
sed 's;HOME="/export/xyz" ;HOME=/"export/xyz1;"' /etc/abc > /etc/abc.new
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove the text between all curly brackets from text file?

Hello experts, I have a text file with lot of curly brackets (both opening { & closing } ). I need to delete them alongwith the text between opening & closing brackets' pair. For ex: Input:- 59. Rh1 Qe4 {(Qf5-e4 Qd8-g8+ Kg6-f5 Qg8-h7+ Kf5-e5 Qh7-e7+ Ke5-f5 Qe7-d7+ Qe4-e6 Qd7-h7+ Qe6-g6... (6 Replies)
Discussion started by: prvnrk
6 Replies

2. Shell Programming and Scripting

sed to remove text from file

Trying to use sed to, in-place, remove specific text from a file. Since there are / in the text I use | to escape that character. Thank you :). sed -i -e 's|xxxx://www.xxx.com/xx/xx/xxx/.*/|' /home/cmccabe/list sed: -e expression #1, char 51: unterminated `s' command (4 Replies)
Discussion started by: cmccabe
4 Replies

3. Windows & DOS: Issues & Discussions

2 Questions: replace text in txt file, add text to end of txt file

so... Lets assume I have a text file. The text file contains multiple "#" symbols. I want to replace all thos "#"s with a STRING using DOS/Batch I want to add a certain TEXT to the end of each line. How can I do this WITHOUT aid of sed, grep or anything linux related ? (1 Reply)
Discussion started by: pasc
1 Replies

4. Shell Programming and Scripting

ksh Remove and replace repeated in file

Hi, i need to read a line from a file and count the number of times it appear in, then continuous to the second line with the same. So when i count a line i have to remove all duplicates in the file to not count it another time. while read line do n=$(grep -c $line File) print "$line... (5 Replies)
Discussion started by: ToniX
5 Replies

5. Shell Programming and Scripting

Replace/Remove not specific text in perl

Hello, Consider that i have many files that have the below format: file1 900 7777 1000 5 6 23 nnnnnnnnnnnnnnnnnn 1100 kkkkkkk file2 900 1989 1000 5 3 10 kkkdfdfdffd 1100 kkkkkkk What i would like to do is on every file to search the line that starts with... (4 Replies)
Discussion started by: chriss_58
4 Replies

6. UNIX for Advanced & Expert Users

Locate text in file then remove and replace

I'm trying to locate a block of text in a file, remove it and then replace with a new block. I can find the first line number that the text starts on using grep -n. I then need to locate the ending line by searching for the string "}" that follows the line I found. Here's the steps I need to... (1 Reply)
Discussion started by: lchandle
1 Replies

7. Shell Programming and Scripting

what command is used to remove the all text of the particular file.

Hi all... I want to delete the entire text of the file and want to make it zero byte.. would you please tell me the command for it. Thanks and regards Vijay sahu (4 Replies)
Discussion started by: vijays3
4 Replies

8. Shell Programming and Scripting

How to replace text in a file with text entered

I am trying to write a shell script that will allow the typing of a value, then using that value to replace data in a text file. I suspect I need sed. The format of the file is: Variable1:Value1 Variable2:Value2 The interaction would be something like: Shell Prompt: "Please enter the... (9 Replies)
Discussion started by: cleanden
9 Replies

9. UNIX for Dummies Questions & Answers

search and replace a specific text in text file?

I have a text file with following content (3 lines) filename : output.txt first line:12/12/2008 second line:12/12/2008 third line:Y I would like to know how we can replace 'Y' with 'N' in the 3rd line keeping 1st and 2nd lines same as what it was before. I tried using cat output.txt... (4 Replies)
Discussion started by: santosham
4 Replies

10. Shell Programming and Scripting

remove specified text from file

I am trying to write a script that kills old sessions, I've posted here over the past few days and the script is just about perfect except I want to be given the option to exclude specified PIDs from being killed. this is the entire script: if then rm /tmp/idlepids fi if then rm... (2 Replies)
Discussion started by: raidzero
2 Replies
Login or Register to Ask a Question