Needing help with searching and replace in a file (sed?)
Hello,
I'm wondering where I could go to learn how to edit file sections that cross multiple lines. I'm wanting to write scripts that will add Gnome menu entries for all users on a system for scripts I write, etc. I can search an replace simple examples with sed, but this seems more complex.
I am on a 'doz system in a hotel right now so I can't post the actual file, but the Gnome menu entry has a structure similar to this:
Say I need to change the markups for the dasher.desktop file from <Exclude> to <Include> and </Exclude> to </Include>?
What If I wanted to add a new <Include></Include> section for a new .desktop file?
Compounding this is that there is variable whitespace indentation depending on how deep into the structure one needs to go and it would be nice to keep the formatting for readability and a nicer, more polished look.
Basically, what is the technique for finding something, and then modifying something on lines above and/or below it OR finding a section, and then adding something on a line below that section without modifying that line in the process.
I don't mind learning myself, but I need pointed in the right direction. I'm not sure where to start. This seems like a bit of a big job for sed. If someone would want to code an example, I'm up for that too as I can learn from that (hey, learning is fun, right?)
Hello:
I have the following HTML table:
<table>
<thead>
<tr>
<th>Code</th>
<th>Percentage</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>30%</td>
</tr>
<tr>
<td>2</td>
... (3 Replies)
Hi All,
I am preserving OLD and NEW values and want to replace the values in one go instead of using multiple sed and mv commands. Please help.
echo "\nEnter the new qStart time '${CODE}' - (Hit Enter for No Change): \c"
read NEW
echo "\nEnter the new qStop time '${CODE}' - (Hit Enter for... (2 Replies)
GM,
I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed.
I am assuming that sed, awk or even perl could do what I need.
I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Hello Team,
I want to know if there is any one liner command , using which I can edit multiple column of a file.
input file input.txt (comma separated),
taran, 12.45, uttam, 23.40, babay
karan, 12.45, raju, 11.40, rahulg
I want to update, 2nd and 4th column,
but want all those column... (8 Replies)
Hi,
I lack the utter fundamentals on how to craft an awk script.
I have hundreds of text files that were mangled by .doc format so all the lines are broken up so I need to join all of the lines of text into a single line. Normally I use vim command "ggVGJ" to join all lines but with so many... (3 Replies)
Is it possible to do this with sed?
Go from this:
958211 XXYYXXYYXX file1 file2 file3
958897 XXYYXXYYXX file1 file2
To this:
file1 file2 file3 XXYYXXYYXX 958211
file1 file2 XXYYXXYYXX 958897
The only thing consistant is XXYYXXYYXX. The numbers and files vary in length. I have seen I... (5 Replies)
Greetings,
I have a file: hostnames.txt which has -
# cat hostnames.txt
machine1
machine2
I need the output to be saved to a variable as:
HOSTNAMELIST=machine1,machine2
Please advise.
Thanks,
Chiru (3 Replies)
I have a file that I need to parse multiple sections from the file.
The file contains multiple lines that start with ST (Abunch of data)
Then the file contains multiple lines that start with SE (Abunch of data)
SE*30*0001
ST*810*0002
I need all of the lines between and including these.... (6 Replies)
I have a file that I need to parse multiple sections from the file.
The file contains multiple lines that start with ST (Abunch of data)
Then the file contains multiple lines that start with SE (Abunch of data)
SE*30*0001 ... (1 Reply)
Hi
I have a config file with multiple section and a parameter with the same name in each section. I need to read each parameter for distinct section.
Parameter = 1
....
Parameter = 2
....
Parameter = 4
....
Tried this:
grep -m1 '^*ProcessorsNumber' ServiceBrokerFramework.cfg |... (7 Replies)