Adding a word into a file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding a word into a file.
# 1  
Old 06-19-2009
Adding a word into a file.

Dear friends,
I am facing a problem with a flat file, to solve that file i need to add certain character in the file which I am not able to do because of "$" sign in the pattern.

Situation is as follows.
Flat file has word RMM$CART
I want to reple this word by RMM$CART DFD

The dollar "$" sign is creating problem.

Kindly suggest me the solution.
Thank you in advance

Anushree
# 2  
Old 06-19-2009
Sure. Please post , what you have tried.
# 3  
Old 06-19-2009
Hi dear,
Thak you for showing your interest.
Following two things I have tried.


find . -name "BMEZINE_TATTOOS" -print -exec sed "s/\RMM$CART/RMM$CART DFD/g;" {} \; > BMEZINE_TATTOOS_DFD

find . -name "BMEZINE_TATTOOS" -print -exec perl -pi -e "s/RMM$CART/RMM$CART DFD/g;" {} \;
# 4  
Old 06-19-2009
Try this...
Code:
sed 's/RMM$CART/RMM$CART DFD/g'

# 5  
Old 06-19-2009
you need to escape the $ symbol since it has a special meaning in Perl and sed:
Code:
find . -name "BMEZINE_TATTOOS" -print -exec perl -pi -e "s/RMM\$CART/RMM\$CART DFD/g;" {} \;

# 6  
Old 06-20-2009
find . -name "BMEZINE_TATTOOS" -print -exec sed "s/RMM\$CART/RMM\$CART DFD/g;" {} \; > BMEZINE_TATTOOS_DFD
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Adding word in blank space

Hi, var=QSB SBD SDN SGJ SJP SKB SKD SLP SML SNB SRE SRG STP TAJ UMP UNO VKS VND VNS WAH ZRR I have to put *.sql after every word What I did echo $var>/root/file1.sql sed -i 's/ /*.sql /g' file1.sql cat file1.sql Output QSB*.sql SBD*.sql SDN*.sql SGJ*.sql SJP*.sql SKB*.sql... (9 Replies)
Discussion started by: kaushik02018
9 Replies

2. Shell Programming and Scripting

adding text before and after a word

Hello, I have a list: i.e: 40331786 50331787 30331788 30331789 30331790 50331791 50331792 50331793 70331794 70331795 70331796 ... ... and I need to add text before and after each number: (2 Replies)
Discussion started by: drbiloukos
2 Replies

3. Shell Programming and Scripting

Script for adding a word in front of all line in a file

Hi I've one file full of paths of certain files and I want to add some extra file words in front of all the paths. for eg: i have a file name test.txt which show some details only.. 024_hd/044/0344eng.txt 035_bv/222/editor.jpg here I want to add /usr/people/indiana/ infront of all the... (4 Replies)
Discussion started by: ratheeshp
4 Replies

4. Shell Programming and Scripting

Adding extra word from file1 to file2

I need to add a word from file1 to file2 accordinggly... file1 contains name of servers and file2 version of server I need that information in a single file so that the format is server_name : version I been trying but havent been able to figure out how to search for a file using sed... ... (14 Replies)
Discussion started by: eponcedeleonc
14 Replies

5. Shell Programming and Scripting

Adding Characters to a Word List

If I had a word list with a large amount of words in it, how would I (using a unix command) add, say, 123 to the end of each word? EDIT: The word list is stored in a large text file. I need a command that applies the ending to each word in the file and saves the result in a new text file. (7 Replies)
Discussion started by: evillion
7 Replies

6. Shell Programming and Scripting

Help adding a key word search to my script

Hello: I need help adding a key word search to my bash script. I have the following script. My boss whats the user to be able to add a search word e.g. unknown failures for the script to search the logs through and find the instances. I had originally done it so it grepped for unknown... (8 Replies)
Discussion started by: taekwondo
8 Replies

7. Shell Programming and Scripting

adding single word to multiple line.

I have following problem. <File A> contains let say 5 lines but can be changed. cat dog fish car if I want to add word to each line then how do I go about it? I used paste -d but that requires two files having same number of lines but in my case <File A> changes and I just need to... (6 Replies)
Discussion started by: paulds
6 Replies

8. Shell Programming and Scripting

sed for adding word

hello i have a file (myfile) contains line as follows /home/mytarget/myproject i want to add a pattern at the end of this line. my pattern is- /.*mk i want like it - /home/mytarget/myproject/*.mk i tried sed like sed 's/$//*.mk/' myfile > newfilename, but not wrking. pls... (2 Replies)
Discussion started by: shailesh_arya
2 Replies

9. Shell Programming and Scripting

Adding a word in front of a word of each line.

Adding a word in front of a word of each line.In that line only one word will be there. pl help:( (4 Replies)
Discussion started by: Ramesh Vellanki
4 Replies

10. Shell Programming and Scripting

adding text to the end of lines containing a word

I'm new to shell scripting, and need to add a series of commands to the ends of certain lines of text that contain a keyword. Any easy way to do this? Thanks (2 Replies)
Discussion started by: ironwall
2 Replies
Login or Register to Ask a Question