I have a input file inputfile which looks like below
I also have a file called param which looks like below
I am trying to extract All lines from inputfile between [MESSAGE BEGIN] and [MESSAGE END] --inclusive (i.e want the [MESSAGE BEGIN] and [MESSAGE END] ) and would want this for the FIRST N lines.....where N would be the number from the param file which comes right after the fixed string NUMBER_OF_TIMES ( in the above example of param file -- N=8 )
What would be the best approach to go about this ?
Should I be using "sed" ?
Am limited to ksh in Linux
Last edited by Don Cragun; 09-01-2015 at 11:16 PM..
Reason: Add CODE and ICODE tags. Add I tags.
If this is not homework, please explain what real-life problem this request is intended to solve. And, note that there is a big difference between number of "lines" in a file and a number of [MESSAGE BEGIN] to [MESSAGE END] blocks of text. It isn't at all clear whether you are talking about "lines" or "blocks".
And, no... sed is not the tool to use for this job. (At least not for the complete job. It could be used for one or two parts of the job, but there are better tools for grabbing a number out of one file and processing another file based on that number.)
thanks for the reply. when referring to N number of times , i mean N number of BLOCKS and not N number of lines.
This is for a situation where I have a inputfile with thousands of XML blocks, all these "different" XML blocks are enclosed within the [MESSAGE BEGIN] and [MESSAGE END] .
Now I would need to create a much smaller "subset" file outputfile which does not need ALL the XML blocks but N number of blocks between [MESSAGE BEGIN] and [MESSAGE END] (inclusive )
Doing this manually --i.e getting rid of thousands of blocks manually takes a lot of time -- plus its a very crude method. Hence am trying to use Shell Scripting to achieve this.
Hi,
I have a log file (log.txt) that which contains lines of date/time.
I need to create a script to extract a CSV file (out.csv) that gets all the sequential times (with only 1 minute difference) together by stating the start time and end time of this period.
Sample log file (log.txt)
... (7 Replies)
Dear friends,
I have a file with the text:
href="/archive/ip=x.x.x.x">M</a></td>
I want to extract just the IP number. I tried sed, awk but i didn't succeed.
Any idea?
Thank you
Please view this code tag video for how to use code tags when posting code and data. (3 Replies)
Hello,
i'm trying to implement the times() function and i'm programming in C.
I'm using the "struct tms" structure which consists of the fields:
The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling process.
The tms_stime structure... (1 Reply)
Hi I have something like this:
EXAMPLE 1
CREATE UNIQUE INDEX "STRING_1"."STRING_2" ON "BOSNI_CAB_EVENTO"
("CD_EVENTO" , "CD_EJECUCION" ) PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 5242880 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "DB1000_INDICES_512K"... (4 Replies)
Hi,
I have a text file like
Version=abc
Tab=1
URL GOTO=www.abc.com/board=1
some text...
I want to run a loop x no of times and append to the text file above text but
URL GOTO should be www.abc.com/board=2 then 3,4...etc till x.
Kindly help (2 Replies)
Hi all,
my problem is extract a value from a text, i mean, I have this text:
> ala
Nr of active alarms are: 16
================================================================================================
Sever Specific Problem Cause Mo-Reference... (15 Replies)
I executed a following sed command
=> echo "a/b/c/d/e/f/g/h" | sed 's/\/*$//g'
a/b/c/d/e/f/g
Now what if I want to extract "g" from "a/b/c/d/e/f/g/h" . That is second last string using SED. (4 Replies)
needa c program to extract text between two delimiters from some text file.
and then storing them in to diffrent variables ?
text file like 0:
abc.txt
=========
aaaaaa|11111111|sssssssssss|333333|ddddddddd|34343454564|asass
aaaaaa|11111111|sssssssssss|333333|ddddddddd|34343454564|asass... (7 Replies)