Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Echo Question 1

Status
Not open for further replies.

stu78

Programmer
May 29, 2002
121
0
0
GB
Hi,

I need to find a certain line is a properties file, and echo some parameters after this point.

the echo part is fine, however, how do I tell echo to start at a certain point in a text file?

e.g.

find the <Object="new"> line and echo the following JUST below;

echo <Object="new1">

then exit script as echo does...
 
Hi,

No, I want to go to a certain line in a properties file & echo the line echo <Object="new1"> there....

 
maybe a small script like this :

var="Object=\"new\""
while read -r line
do
if [[ $line = $var ]]
then
echo $line
exit
fi
done < input.file
 
Something like this ?
awk '1/<Object="new">/{print "<Object=\"new1\">"}' /path/to/input

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PV,

This does not work like I would like it to.. but it is a good start...

I need to find the <Object="new"> line in and write to JUST below that;
 
Please post input example and expected result.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
ok - so I have a file ( properties.txt ) ...

<Object="new">
<Object="new2">
<Object="new3">


And I need to put <Object="new1"> so the file looks like;

<Object="new">
Object="new1">
<Object="new2">
<Object="new3">


Sorry if I have not been clear on this....
 
And this ?
awk '{print}/\<Object="new"\>/{print "<Object=\"new1\">"}' /path/to/input

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PV,

This outputs me the same file as I fed in.


$ awk '{print}/\<Object="new"\>/{print "<Object=\"new1\">"}' file.txt
<Object="new">
<Object="new2">
<Object="new3">

Any Ideas?
 
And this ?
awk '{print}/<Object="new">/{print "<Object=\"new1\">"}' file.txt

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
That's perfect - thanks a million
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top