Dynamically accept search pattern and display lines based on it
I have a output file which contains n number of document.Each document has n number of segments and identified using below points
The starting segment is ISA and Ending segment is IEA
Each document has unique number and it will be passed in REF*D9 segment
Each line in sample file is called segment and each segment is group of field delimited with (*)
Since i cant paste the entire contents i have attached the sample file.
Refer the sample file for exact file structure.
If i need to display particular segment from large sample file
I used the following commands
if i need N4 segment which is under NM1*85 segment for same set of documents then i use
so for each and every segment i need to type the command again and store the output in seperate file
I am novice to unix i got this idea if anybody can come up with better logic that will handle my requirement
it would be appreciable
A shell loop can ask for the pattern, capture matching lines in a temp file, count the lines at the same time, and if any lines, turn you over to vi, pg, less in the temp file to view and play in the subset. When you exit the viewer, it asks you if you want to view again, and if not, loops. You can make any copies you want from inside the viewer.
Now, only a select few actually prefer the csh. The bash and ksh93 are much nicer and there are more experts to help.
PS: I use the ksh/bash 'set -o vi' option to do command recall, so I do not type commands over and over. I never even leave my home dir except inside (...) so I return automatically. It makes the history more valuable. I also save the history file occasionally where my tools can find it, and set a huge HISTSIZE of 32767. I consider one of the best CUI's.
Last edited by DGPickett; 03-07-2013 at 02:46 PM..
Hi I need to grep for a patter and display all lines below the pattern.
For ex: say my file has the below lines
file1
file2
file3
file4
file5
I NEED to grep for patter file3 and display all lines below the pattern. do we have an option to get this data. Let me know if you require... (5 Replies)
Hi,
I've written a script to search for an Oracle ORA- error on a log file, print that line and the .trc file associated with it as well as the dateline of when I assumed the error occured. In most it is the first dateline previous to the error.
Unfortunately, this is not a fool proof script.... (2 Replies)
Hi team,
Is it possible to display 2 lines after a particular pattern in a shell script. For example in a file which has the below contents.
Mummy
Daddy
Son
Daughter
Children
Aunty
Uncle
Grandma
Grandpa
Son
Father
Mother
Brother-in-law
I want to display 2 lines before and after... (1 Reply)
I have a file with following data
<Field FieldName="CHCFA21_01_01" FieldType="Text">
<Output CapturedValue="">
<DataSource Name="" Value="" />
</Output>
</Field>
<Field FieldName="CHCFA21_01_02" FieldType="Date">
<Output CapturedValue="">
... (1 Reply)
i have something like this in a file called mysqldump.sql
--
-- Table structure for table `Table11`
--
DROP TABLE IF EXISTS `Table11`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Table11` (
`id` int(11) NOT NULL... (14 Replies)
Hey folks!
I am new to shell-scripting, but I have a problem that I would like to solve using a script. I create very large html forms, used for randomized trials. In these forms, each question is supplied with a variable that looks something like this: PROJECT_formNN
Where NN is the question... (1 Reply)
Hi all,
I am trying to extract the values ( text between the xml tags) based on the Order Number.
here is the sample input
<?xml version="1.0" encoding="UTF-8"?>
<NJCustomer>
<Header>
<MessageIdentifier>Y504173382</MessageIdentifier>
... (13 Replies)
hiii,
i have to write a shell script like this----
i have a huge log file name abc.log .i have to search for a pattern name "pattern",it may occur 1000 times in the log file,every time it finds the pattern it should display the 10 lines above the pattern.
I appericiate your help. (30 Replies)
I want to search a file for a string and then if the string is found I need the line that the string is on - but also the previous two lines from the file (that the pattern will not be found in)
This is on solaris
Can you help? (2 Replies)