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.
To keep the forums high quality for all users, please take the time to format your posts correctly.
First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)
Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.
Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.
You should use the uppercase version of hold so that the line you took into hold buffer will not be overwritten by the next you take there.
Also the p is not needed when get the buffer.
In the output I get an extra blank line - not sure where it comes from though.
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)
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)
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)
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)
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)
***************
#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)
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)
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)
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)
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)