Thanks sea, please explain here how to work sed command, as you write
Quote:
sed s,Ram,Shyam,g -i file.txt
I could not understand meaning of s, g, -i, please explain it, also I have study many tutorial links from Google but unable to use it, please enhance it or share any good link according your.
Thanks sea, please explain here how to work sed command, as you write
I could not understand meaning of s, g, -i, please explain it, also I have study many tutorial links from Google but unable to use it, please enhance it or share any good link according your.
For explaination part of command is as follows.
Here s is used because we need to do substitute operation, /Ram/Shyam means to replace word Ram with Shyam, g means to do this subtitute operation globally else it will perform this substitute operation only at 1st match of the word, -i will edit the Input_file and save it too. You can refer the man sed page too for same.
s sed command: substitute Ram regexp Shyam replacement g sed pattern flag: global substitution -i sed command line option: "in place" editing
In other words, substitute every occurrence of Ram with Shyam and also change it in the file.
One problem could be that the mentioned sed command doesn't really ensure to match Ram as a single word, so it will also replace Ram in Ramesh, Rammstein and so on, too.
This awk might be more robust for (i=1;i<=NF;i++) in every line, parse every field if ($i == "Ram") { $i = "Shyam" } if a field equals Ram, change that field to Shyam print after all fields in a line are parsed (and potentially modified), print the whole line
I have file1 and file2 as shown below,
file1:
((org14/1-131541:0.11535,((org29/1-131541:0.00055,org7/1-131541:0.00055)1.000:0.10112,((org17/1-131541:0.07344,(org23/1-131541:0.07426,((org10/1-131541:0.00201,org22/1-131541:0.00243)1.000:0.02451,
file2:
org14=india
org29=america... (5 Replies)
Hi All,
I need one help to replace particular words in file based on if finds another words in that file .
i.e.
my self is peter@king.
i am staying at north sydney.
we all are peter@king.
How to replace peter to sham if it finds @king in any line of that file.
Please help me... (8 Replies)
I have the file like this.
cat 123.txt
<p> <table border='1' width='90%' align='center' summary='Script output'> <tr><td>text </td> </tr> </table> </p>
I want to replace some tags and want the output like below. I tried with awk & sed commands. But no luck. Could someone help me on this?
... (4 Replies)
Hello,
I would like to change my setting in a file to the setting that user input.
For example, by default it is
ONBOOT=ON
When user key in "YES", it would be
ONBOOT=YES
--------------
This code only adds in the entire user input, but didn't replace it.
How do i go about... (5 Replies)
Dear all,
I am working with names and I have a large file of names in which some words are written together (upto 4 or 5) and their corresponding single forms are also present in the word-list.
An example would make this clear
annamarie
mariechristine
johnsmith
johnjoseph smith
john
smith... (8 Replies)
Hello,
I have a complex problem. I have a file in which words have been joined together:
Theboy ranslowly
I want to be able to correctly split the words using a lookup file in which all the words occur:
the
boy
ran
slowly
slow
put
child
ly
The lookup file which is meant for look up... (21 Replies)
hello,
i 'd like your help about a bash script which:
1. finds inside the html file (it is attached with my post) the code number of the Latest Stable Kernel,
2.finds the link which leads to the download location of the Latest Stable Kernel version,
(the right link should lead to the file... (3 Replies)
lets see if i can explain this in a good way.
im trying to replace some words in a file but i need to know what the words are that is beeing replaced. not sure if sed can do this.
file.name.something.1DATA01.something.whatever
sed "s/./.DATA?????/g"
need to know what the first . is... (2 Replies)
Hello,
Can someone kindy help me solve this problem..I am using SunOS shell script
I got a file A with following content:
This is my correct document. I wrote 111
This is my incorrect word , 222
This is my wrong statement 333
This is my correct document 444
This is my correct document 555... (9 Replies)
Hi,
I have a Template file 'TL.body' which says as follows:
"There are no <FILENAME> files on the server. "
The missing file names are identified and stored in a variable.
For Eg: MISSFILE="abc.txt def.txt xyz.txt"
I want the values of MISSFILE variable to be replaced against... (2 Replies)