I have the following program:
In this program I need to insert the string $sourceString before line </data-sources>.
My problem is with the parameter $sourceString:
As you can see,The parameter ${sourceString} was not converted.
I tried to add quotation marks before the parameter in the sed command:
And the results are:
......
The problem in this case is that the sed added quotation marks (") in the beginning and in the end of the line.
Which marks and where should I put around the parameter in the sed command?
Thanks for your replies.
I prefer amit_sapre suggestion - echo sed command into file and run it.
My problem is now with the echo command.
I cannot issue the command :
because of the back-slashes (\) and the inverted commas(').
I need the "magic formula" for this echo.
i am having file like this
#!/bin/bash
read -p 'Username: ' uservar
match='<color="red" />'
text='this is only a test
so please be patient
<color="red" />'
echo "$text" | sed "s/$match/&$uservar\g"
so desireble output what i want is if user type MARIA
this is only a test
so please... (13 Replies)
Hi All
I'm trying to insert a new line at the before each comment line in a file.
Comment lines start with '#-----'
there are other comments with in lines but I don't want a new line there.
Example file:
blah
blah #do not insert here
#this is a comment
blah #some more
#another comment... (10 Replies)
I need to read a text file and insert a string every n lines, but also have the line counter restart when I come across a header string.
Line repeating working every 3 lines using code:
sed '0~3 s/$/\nINSERT/g' < INPUT/PATH/FILE_NAME.txt > OUTPUT/PATH/FILE_NAME.txt
I cannot seem to find... (1 Reply)
I have a large file with interface records. I need to check every record that has the string "encapsulation bridge1483" and if the next line after this does not have "ip description" then I need to insert a line to add "ip description blah_blah_blah.
Sample file:
interface atm 1/0.190158... (3 Replies)
Hi all,
can some one help me out
file 1 i have
06/01 3:14 d378299
06/01 8:10 d642036
06/01 10:51 d600441
06/01 10:52 d600441
06/01 11:11 d607339
06/01 11:49 d398706
something like this and in file named list i have ( there is space btwn 06/01 and 11:49 and d398706)
d607339... (5 Replies)
Hi
I need to update a number of existing files and insert #!/bin/ksh line a the first line of the file.
Is there any awk or sed command which would help me to do that instead of doing it manually?
Thanks a lot -A (10 Replies)
I just want to add a particular string in text file using shell script
text file format
1 columns-10
2 text=89
3 no<>
4
5 test-9876
6 size=9
string need to insert in 4th line
<switch IP='158.195.2.567' port='5900' user='testc' password='asdfrp' Code='8'>
After inserting the... (8 Replies)
Hi,, Please excuse my lack of knowledge here. I think I am tring to do something fairly advanced yet am a bit of a beginner.....
I want to use a korn shell (as is the norm with others in my company) to write a script to search a file for a string and insert some text above that line.
Sudo... (5 Replies)
Hi, guys. I have one question:
How can I search for a line with certain string in it and then insert a string into this line?
For example:
There is a file called shadow, the contents of it are below:
**************************
...
yuanz:VIRADxMsadfDF/Q:0:0:50:7:::... (9 Replies)
Hello all
i have big test file that has allot of structure text something like this :
<foo1 *.html>
<blah action>
somthing 1
somthing 2
</blah>
</foo1 >
now i will like to insert 2 more lines of text below the <blah action>
so it will be like :
<foo1... (1 Reply)