Adding a block to the file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding a block to the file
# 1  
Old 08-20-2008
Adding a block to the file

Hi guys,
I am trying to add the content of fileB into fileA but after a specific block within FileA
for instance i have a file that starts as follow:

-------------------------------------------------------------------------------
-- Title :
-- Project :
-------------------------------------------------------------------------------
-- File :
-- Author :
-- Company :
-- Created :
-- Last update: 2458/05/14
-- Platform :
-------------------------------------------------------------------------------
-- Description: <cursor>
-------------------------------------------------------------------------------
-- Copyright (c)
-------------------------------------------------------------------------------
-- Date Version Author Description
-- 2098-10-17 1.0 Created
-- 2076-12-11 1.0 Imported from
-- 2747-05-03
--------------------------------------------------------------------------

------------------------------------------------------------------------
--
-- Portions Copyright (c)
-- All rights reserved
--
-- Proprietary and Confidential
--
-- Portions of this code embody materials and concepts which are confidential
-- to and is made available
-- solely pursuant to the terms of a written agreement with
-- .
--
--------------------------------------------------------------------------


...the rest of the code

I need to remove the bold part and add content of fileb under the tilted part.
i am pretty much helpless on this part.
I was wondering if someone could help me with this?

Thanks,
# 2  
Old 08-20-2008
Code:
head -n 22 fileA >newfile
cat fileB >>newfile
tail -n 13 fileA >>newfile
mv newfile fileA

This is a very simple solution if fileA is exactly has you posted. Since you didn't request any pattern matching I figured this is an isolated case.
# 3  
Old 08-20-2008
the problem is that the tilted part could be longer and there are a lot of cases which i could not consider one by one.
secondly there are some code after the bold block and i don't know the exact number of line for each file and then i need to have the exact position where bold block starts(according to ur suggestion)
i apologize for posting such a wage question but this is what i am dealing right now
one more thing, bold block need to be removed. sorry if it is not clear in my previous post; but it seems like u misunderstood my question.
anyhow, I appreciate your help
# 4  
Old 08-20-2008
Well, is there any criteria/pattern on the files? If they have dynamic length and no specific pattern I'm afraid it's impossible.
# 5  
Old 08-20-2008
I just posted another question which is related to this problem, lets say i just focus on removing the bold portion. what could i do about that
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Adding to an array in an external file, and adding elements to it.

I have an array in an external file, "array.txt", which contains: char *testarray={"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};I want to be able to add an element to this array, and have that element display, whenever I call it, without having to recompile... (29 Replies)
Discussion started by: ignatius
29 Replies

2. Shell Programming and Scripting

Printing a block of lines from a file, if that block does not contain two patterns using sed

I want to process a file block by block using sed, and if that block does not contain two patterns, then that complete block has to be printed. See below for the example data. ................................server 1............................... running process 1 running... (8 Replies)
Discussion started by: Kesavan
8 Replies

3. UNIX for Advanced & Expert Users

Move a block of lines to file if string found in the block.

I have a "main" file which has blocks of data for each user defined by tags BEGIN and END. BEGIN ID_NUM:24879 USER:abc123 HOW:47M CMD1:xyz1 CMD2:arp2 STATE:active PROCESS:id60 END BEGIN ID_NUM:24880 USER:def123 HOW:4M CMD1:xyz1 CMD2:xyz2 STATE:running PROCESS:id64 END (7 Replies)
Discussion started by: grep_me
7 Replies

4. Shell Programming and Scripting

Adding content of two file in a single file column wise

Hi, I am trying to get the file in particular pattern using shell script. I have to add one column to some other file. For example consider two file as below. File1: name1 name2 name3 File2: Add1 age1 Add2 age2 Add3 age3 I want this two file in a single file format something like... (3 Replies)
Discussion started by: diehard
3 Replies

5. Shell Programming and Scripting

editing line in text file adding number to value in file

I have a text file that has data like: Data "12345#22" Fred ID 12345 Age 45 Wilma Dino Data "123#22" Tarzan ID 123 Age 33 Jane I need to figure out a way of adding 1,000,000 to the specific lines (always same format) in the file, so it becomes: Data "1012345#22" Fred ID... (16 Replies)
Discussion started by: say170
16 Replies

6. Shell Programming and Scripting

Adding new lines to a file + adding suffix to a pattern

I need some help with adding lines to file and substitute a pattern. Ok I have a file: #cat names.txt name: John Doe stationed: 1 name: Michael Sweets stationed: 41 . . . And would like to change it to: name: John Doe employed permanently stationed: 1-office (7 Replies)
Discussion started by: hemo21
7 Replies

7. Shell Programming and Scripting

finding a block in a file and replace with another file block.

(1) Yes but how is this block different from the other 24? You will need this information in order to identify and replace this block correctly (out of the 25). Ans: The 1st line and last line of this block are unique from other block. The 1st line is “rem Subset Rows (&&tempName.*) and The... (1 Reply)
Discussion started by: Zaheer.mic
1 Replies

8. Shell Programming and Scripting

Need help in sed: adding a line after each search block

Hi friends, I have written script that will search & display the block of sql statement. Since there are many blocks of sql statement i am finding it difficult to distinguish between them. The below is the sed command & its result exec sql abc abc abc... (2 Replies)
Discussion started by: frozensmilz
2 Replies

9. Shell Programming and Scripting

Need help in sed command (adding a blank line btw each block generated by pattern)

Hello friends, I have a C source code containing sql statements. I use the following sed command to print all the sql blocks in the source code.... sed -n "/exec sql/,/;/p" Sample.cpp The above sed command will print the sql blocks based on the pattern "exec sql" & ";"... (2 Replies)
Discussion started by: frozensmilz
2 Replies

10. Shell Programming and Scripting

Need Help for Adding Three new columns in existing file from fatching data from file

not required this time (36 Replies)
Discussion started by: Sandeep_Malik
36 Replies
Login or Register to Ask a Question