replace lines in a file by corresponding lines from another file
Hi all,
I have an EPS file header, with the first lines pasted below. I would like to replace lines, such as the "BoundingBox" field line 9, by the corresponding line from a similar EPS figure (so that the bounding boxes and other parameters are the same and my figures look nice!).
I have seen how to replace a specific line with sed, such as:
Code:
sed '9s/.*/new contents/' < dummy.txt
but I would like to be able to grab the "BoundingBox" line from another file, and paste its content in the current file.
It seems like the line where this field is stays the same, but optimally I would be able to do it by looking for a field and not a line. I would like to do this with an incantation of awk/sed but I'm not very familiar with it.
Hopefully if I understand how to do it for this line I could apply it for other fields.
Thanks for the help.
Code:
%!PS-Adobe-3.0 EPSF-3.0
%%Creator: MATLAB, The Mathworks, Inc. Version 7.10.0.499 (R2010a). Operating System: Linux 2.6.32-32-generic #62-Ubuntu SMP Wed Apr 20 21:52:38 UTC 2011 x86_64.
%%Title: /home/tblum/Documents/papers/source_fracture/figs/field-all_b.eps
%%CreationDate: 06/14/2011 11:04:07
%%DocumentNeededFonts: Helvetica-Bold
%%DocumentProcessColors: Cyan Magenta Yellow Black
%%LanguageLevel: 2
%%Pages: 1
%%BoundingBox: 89 148 502 631
%%EndComments
I have a file where every line includes four expressions with a caret in the middle (plus some other "words" or fields, always separated by spaces). I would like to extract from this file, all those lines such that each of the four expressions containing a caret appears in at least four different... (9 Replies)
Replace first 3 characters in a unix file (say replace "A&B" with "C&D") in all lines of the file. Need a sed or awk script to do this. Kindly help!
-Kumar (4 Replies)
Hi everybody,
I am a newbie in shell scripting and I'm trying to write a script which reads lines from a file, searching some of this lines to change a specified number. I want to replace the line for another in the file.
I have to replace multiples lines, so I have a for. Now I am trying with... (1 Reply)
Hello,
I have 8 lines containing these unique words in both files
645147468537
673962863160
673962864957
691717701950
707917019907
790085591726
792975507744
852174812753
file.dat.orig (has 1000 lines) and file.dat(has only 8 lines)
I want to replace those lines in file.dat.orig by... (1 Reply)
Hi all,
I have two parameter blocks in a configuration file, file1.conf.
First parameter block starts with PWAT-PARM1 and
ends with END PWAT-PARM1.
Second parameter block starts with PWAT-PARM2 and
ends with END PWAT-PARM2 (please see below in file1.conf).
file1.conf is fixed width... (8 Replies)
I've got a file full of numbers, example:
cat test.file
60835287
0
51758036
40242437
0
32737144
0
24179513
0
4131489957
I want to replace those numbers (4 Replies)
Hello
I am a beginner in shell script.
I was trying to find a way to replace multiple lines of a file with different set of multiple line.
sed -n '/begin/,/end/p' < sample1.txt >test.txt
UNEDITED=`cat test.txt`
vi test.txt
EDITED=`cat test.txt`... (2 Replies)
Hi all,
I am new to UNIX, so sorry if my question seem stupid to u.
well i want to replace the first character of first 30 lines of a file, only if the first character is h.
and
in anothe script i want to replace a particular string/character say hello/h of a file.Condition: It should... (1 Reply)