09-21-2009
moving text with sed
Hi,
I have a configuration file for solaris zones that I generate as part of another script but I need to move part of the text to the end of the file prior to execution and I'm having problems getting the syntax correct on the sed command.
The file looks like this:
create -b
set zonepath=/export/zones/fred
set autoboot=false
set ip-type=shared
add net
set address=1.1.1.1
set physical=nxge0
end
add net
set address=1.1.1.2
set physical=nxge7
end
add rctl
set name=zone.max-swap
add value (priv=privileged,limit=2147483648,action=deny)
end
add dedicated-cpu
set ncpus=2
end
add capped-memory
set physical=2G
end
The lines in bold need to be moved to the end of the file so I tried using the following command in sed but can't get it working.
sed '/rctl/,/end/{h;d};${g;p;}' /tmp/filename
It pattern matches the correct lines and deletes them but doesn't print them at the end of the file.
What have I done wrong?
Thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have this text in a file where I need to move part of the text....
<Relation1 OriginatingObjectID="Holding_1" RelatedObjectID="Party_1" id="Relation_1">
<OriginatingObjectType tc="4">Holding</OriginatingObjectType>
<RelatedObjectType tc="6">Party</RelatedObjectType>... (4 Replies)
Discussion started by: mgirinath
4 Replies
2. Shell Programming and Scripting
I trying to extract certain text from a csv file and then placing it into another csv file, but having problems getting the data to placed in one line with tab separated fields.
Basically would like to have text sent to interfaces.csv in one line seperated by tabs. As it currently places files... (6 Replies)
Discussion started by: 00000008
6 Replies
3. Shell Programming and Scripting
Hi,
I need convert a dump file in the following format : (please note that line numbers are provided for easy look)
Original file:
1 2007-10-2482.90 No trade 0 0.00 100000.00
2 100000.00
3 0.00
4 HOLD
5 2007-10-2589.75 Bought 1114 1114 100000.00 0.00
... (5 Replies)
Discussion started by: sabyasm
5 Replies
4. Shell Programming and Scripting
Hi all,
I need to insert new text and change existing text in a file. For that I used the below line in the command line and got the expected output.
sed '$a\
hi...
' shell > shell1
But I face problem when using the same in script. It is throwing the error as,
sed: command garbled:... (4 Replies)
Discussion started by: iamgeethuj
4 Replies
5. Shell Programming and Scripting
***************
#some other text
*****************
***************
#some other text
*****************
address1=1.1.1.1
address2=2.2.2.2
address3=3.3.3.3
I have a file where i need to push all the text starting from address1 till end of file to, below . Can anyone of you... (6 Replies)
Discussion started by: srikanthgoodboy
6 Replies
6. Shell Programming and Scripting
I want to mvoe lines around in a file.
Say I have 30 lines in a file and want to move the last 5 lines to the top of the file..how can this be done?
i thought of awk and sed but was not sure context.
please assist
thanks (5 Replies)
Discussion started by: sigh2010
5 Replies
7. Shell Programming and Scripting
Hi all,
First off, Thank you all for the knowledge I have gleaned from this site!
Deleting Records from a text file... sed paragraphs
The following code works nearly perfect, however each time it is run on the log file it adds a newline at the head of the file, run it 5 times, it'll have 5... (1 Reply)
Discussion started by: Festus Hagen
1 Replies
8. UNIX for Dummies Questions & Answers
Hi There!
I've got a tab delimited text file (output from a software) to which I would like to delete specific strings from one of the columns. I have tried several sed codes, but they do not seem to work for me. I can manage to delete a specific word, but this is of no use, as I what I want to... (3 Replies)
Discussion started by: alfredman
3 Replies
9. Shell Programming and Scripting
I have some html with hrefs that contain local links to pdf filenames. These filenames should have standardised names, i.e. there should be a label prior to the ".pdf" filename suffix. There can be many of these links on a single line of text and some may already have the label. For example
... (13 Replies)
Discussion started by: adb
13 Replies
10. Shell Programming and Scripting
hello everyone,
im new here, and also programming with awk, sed and grep commands on linux.
In my text i have many lines with this config:
1 1 4 3 1 1 2 5
2 2 1 1 1 3 1 2
1 3 1 1 1 2 2 2
5 2 4 1
3 2 1 1 4 1 2 1
1 1 3 2 1 1 5 4
1 3 1 1... (3 Replies)
Discussion started by: satir
3 Replies