You might also want to try the following:
Obviously, you'll need to change the path shown in red to a path naming the directory in which you want to process your files.
If sed fails for some reason, it won't destroy the file you were trying to update (which RavinderSingh13's suggestion might do if the awk fails).
If there are any hard links to any of the files being processed, this script will maintain those links. (The code RavinderSingh13 suggested will break the links, if there are any, creating two separate (unlinked) files.)
This would probably also work with /usr/bin/sed on Solaris systems, but I'm almost positive it will work with /usr/xpg4/bin/sed. Unfortunately, I don't have a Solaris system available for testing.
I need to insert a file called temp_impact (which has about 15 lines in it) to a file called 11.23cfg starting at line 33. I searched the forums and found the
sed '34i\
test' 11.23cfg > newfile
That will enter word test at the appropriate line, but i need the entire file dumped there. Any... (4 Replies)
how to insert a extra line in a text file using a sh command
iam trying to think of a way to add a extra line but without deleting the whole text
do anyone have any ideas (2 Replies)
So I need to write lines into line X of file X.
I can get the file by doing:
cfgnumber=$(cat -n -comm.cfg| grep -i "servicegroup_name 24x7-comunicacions")
echo $cfgnumber
it outputs the Line where it finds now I need to start writing something right bellow that line.
thanks (10 Replies)
Dear Folks :),
I am new to UNIX scripting and I do not know how can I insert some text in the first column of a UNIX text file at command promtp.
I can do this in vi editor by using this command :g/^/s//BBB_
e,g I have a file named as Test.dat and it containins below text:
michal... (4 Replies)
sed '1r file.txt' <source.txt >desti.txt
This example will insert 'file.txt' between line 1 and 2 of source.txt.
sed '0r file.txt' <source.txt >desti.txt
gives an error message.
Does anyone know how 'sed' can insert 'file.txt' before the first line of source.txt? (18 Replies)
Hello,
I am trying to add a line (usually just a word) to some text files in a directory that are already sorted. I just don't want to run the sort command again because it can take a long time when the text or log files are really huge. I have a bashscript that will take in the 1st argument... (7 Replies)
Hi,
For my reuirement, I have to read a file from the 2nd line till the last line<EOF>.
Say,
I have a file as test.txt, which as a header record in the first line followed by records in rest of the lines.
for i in `cat test.txt`
{
echo $i
}
While doing the above loop, I have read... (5 Replies)
I have a test file that I want to read and insert only certain lines into the
the table based on a filter.
1. Rread the log file 12 Hours back Getdate() -12 Hours
2. Extract the following information on for lines that say "DUMP is
complete"
A. Date
B. Database Name
C.... (2 Replies)
My file (the output of an experiment) starts off looking like this,
_____________________________________________________________
Subjects incorporated to date: 001
Data file started on machine PKSHS260-05CP
**********************************************************************
Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies
LEARN ABOUT MINIX
roff
is a text formatter. Its input consists of the text to be out-
put, intermixed with formatting commands. A formatting commandis a line containing the control character followed by a twocharacter command name, and possibly one or more arguments. Thecontrol character is initially . (dot). The formatted output isproduced on standard output. The formatting commands are listedbelow, with being a number, being a character, and being a title.A + before n means it may be signed, indicating a positive ornegative change from the current value. Initial values for whererelevant, are given in parentheses.
.ad Adjust right margin.
.ar Arabic page numbers.
.br Line break. Subsequent text will begin on a new line.
.bl n Insert n blank lines.
.bp +n Begin new page and number it n. No n means +1.
.cc c Control character is set to c.
.ce n Center the next n input lines.
.de zz Define a macro called zz. A line with .. ends definition.
.ds Double space the output. Same as .ls 2.
.ef t Even page footer title is set to t.
.eh t Even page header title is set to t.
.fi Begin filling output lines as full as possible.
.fo t Footer titles (even and odd) are set to t.
.hc c The character c (e.g., %) tells roff where hyphens are permitted.
.he t Header titles (even and odd) are set to t.
.hx Header titles are suppressed.
.hy n Hyphenation is done if n is 1, suppressed if it is 0. Default is 1.
.ig Ignore input lines until a line beginning with .. is found.
.in n Indent n spaces from the left margin; force line break.
.ix n Same as .in but continue filling output on current line.
.li n Literal text on next n lines. Copy to output unmodified.
.ll +n Line length (including indent) is set to n (65).
.ls +n Line spacing: n (1) is 1 for single spacing, 2 for double, etc.
.m1 n Insert n (2) blank lines between top of page and header.
.m2 n Insert n (2) blank lines between header and start of text.
.m3 n Insert n (1) blank lines between end of text and footer.
.m4 n Insert n (3) blank lines between footer and end of page.
.na No adjustment of the right margin.
.ne n Need n lines. If fewer are left, go to next page.
.nn +n The next n output lines are not numbered.
.n1 Number output lines in left margin starting at 1.
.n2 n Number output lines starting at n. If 0, stop numbering.
.ni +n Indent line numbers by n (0) spaces.
.nf No more filling of lines.
.nx f Switch input to file f.
.of t Odd page footer title is set to t.
.oh t Odd page header title is set to t.
.pa +n Page adjust by n (1). Same as .bp
.pl +n Paper length is n (66) lines.
.po +n Page offset. Each line is started with n (0) spaces.
.ro Page numbers are printed in Roman numerals.
.sk n Skip n pages (i.e., make them blank), starting with next one.
.sp n Insert n blank lines, except at top of page.
.ss Single spacing. Equivalent to .ls 1.
.ta Set tab stops, e.g., .ta 9 17 25 33 41 49 57 65 73 (default).
.tc c Tabs are expanded into c. Default is space.
.ti n Indent next line n spaces; then go back to previous indent.
.tr ab Translate a into b on output.
.ul n Underline the letters and numbers in the next n lines.