Sponsored Content
Top Forums Shell Programming and Scripting How to extract a text portion from a file Post 302332491 by ejazs0 on Thursday 9th of July 2009 09:02:44 AM
Old 07-09-2009
Hi Thanks

awk '/Name: xyz/,/end of text/ {print}' infile

is working fine!!

One more small request..

If the pattern of the input file is

line1..
line2..
Name: abs
Some tesxt....
Some tesxt....
Some tesxt....
end of text
line1..
line2..
Name: xyz
Some tesxt....
Some tesxt....
Some tesxt....
end of text
line1..
line2..
Name: efg
Some tesxt....
Some tesxt....
Some tesxt....
end of text

how to get the output file as

line1..
line2..

Name: xyz
Some tesxt....
Some tesxt....
Some tesxt....
end of text

using awk
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Separate a portion of text file into another file

Hi, I have my input as follows : I have given two entries- From system Mon Aug 1 23:52:47 2005 Source !100000006!: Impact !100000005!: High Status ! 7!: New Last Name+!100000001!: First Name+ !100000003!: ... (4 Replies)
Discussion started by: srikanth_ksv
4 Replies

2. Shell Programming and Scripting

extract a portion of log file

hello, I want to grep the log file according to time and get the portion of log from one particular time to other. I can grep for individual lines by time but how should I print lines continuously from given start time till end till given end time. Appreciate your ideas, Thanks chandra (8 Replies)
Discussion started by: chandra004
8 Replies

3. Shell Programming and Scripting

extract date portion from file

Hi, I have a file where there is a date field (single line variable length file) how to extract just the date portion from it the position of date field may vary anywhere in the line but will always have the format mm-dd-yyyy for eg . xxxxxxxxxxxxxxx09-10-2006xxxxxxxxxxxxxxxxxxxx (5 Replies)
Discussion started by: misenkiser
5 Replies

4. UNIX for Dummies Questions & Answers

How to extract a portion of text from a log file

I am using Unix on Mac OS X 10.5.6. I am trying to extract the last entry of a log (text) file. As seen below, each log entry looks like the following (date and time change with each log entry): I want the script to extract everything quoted above, including the "===" dividers. ... (2 Replies)
Discussion started by: atilano
2 Replies

5. Shell Programming and Scripting

extract string portion using sed

Hi All I have 3 files as listed below and highlighted in bold the portions of the filenames I need to extract: TOS_TABIN218_20090323.200903231830 TOS_TABIN219_1_20090323.200903231830 TOS_TABIN219_2_20090323.200903231830 I tried source_tabin_name=`echo $fname | sed 's/_.*//'` but I... (6 Replies)
Discussion started by: santam
6 Replies

6. Shell Programming and Scripting

Extracting a portion of data from a very large tab delimited text file

Hi All I wanted to know how to effectively delete some columns in a large tab delimited file. I have a file that contains 5 columns and almost 100,000 rows 3456 f g t t 3456 g h 456 f h 4567 f g h z 345 f g 567 h j k lThis is a very large data file and tab delimited. I need... (2 Replies)
Discussion started by: Lucky Ali
2 Replies

7. Shell Programming and Scripting

parsing a portion of Data from a text file

Hi All, I need some help to effectively parse out a subset of results from a big results file. Below is an example of the text file. Each block that I need to parse starts with "Output of GENE for sequence file 100.fasta" (next block starts with another number). I have given the portion of... (8 Replies)
Discussion started by: Lucky Ali
8 Replies

8. Shell Programming and Scripting

How to extract portion of a string?

Hi Gurus, Would like to seek some help on how to extract a portion of string from log's output as shown below. Sample of raw data: piece handle=/test123/disk_dump/test123/df0_cntrl_PCPFCI20120404_68498 tag=TAG20120404T180035 comment=NONE piece... (13 Replies)
Discussion started by: superHonda123
13 Replies

9. Shell Programming and Scripting

Extract portion of data

Hi Gurus, I need some help in extracting some of these information and massage it into the desired output as shown below. I need to extract the last row with the header in below sample which is usually the most recent date, for example: 2012-06-01 142356 mb 519 -219406 mb 1 ... (9 Replies)
Discussion started by: superHonda123
9 Replies

10. UNIX for Beginners Questions & Answers

Extract a portion of string from each line in Linux

Hi I have to extract the destination path information from each record the file is of variable length so I will not be able to use the print command.The search should start on variable "destinationPath" and it should end at immediate "," also the first field has to be printed Input File:... (7 Replies)
Discussion started by: rkakitapalli
7 Replies
TextDisplay(3I) 					    InterViews Reference Manual 					   TextDisplay(3I)

NAME
TextDisplay - unstructured text display SYNOPSIS
#include <InterViews/textdisplay.h> DESCRIPTION
A TextDisplay manages and displays an array of lines of text. Operations are provided to insert and delete lines, to insert and delete text within a line, and to scroll the display. TextDisplays are typically used to implement interactors that require non-trivial display of unstructured text. The array is addressed by a line number and an index into the line. Text can be inserted or deleted at arbitrary positions. By default, the first character in line number zero is positioned with its top left corner at the top left corner of the TextDisplay. The display is automatically updated following modifications to the text or when scrolling. Each character in the array has an associated text style. Operations are provided to apply, add, or remove font styles to a range of the text. TextDisplay can be used with both constant-width and proportionally-spaced fonts and with arbitrary geometric transformations. PUBLIC OPERATIONS
TextDisplay() ~TextDisplay(boolean autosized = false) Create or destroy a TextDisplay. If autosized is true, the TextDisplay will automatically grow its size as text is added. The default is to keep the size constant. void LineHeight(Coord lineheight) void TabWidth(Coord tabwidth) Lines of text will be positioned with baselines separated by lineheight. Tab characters in the text will cause the following char- acter to be positioned an integral multiple of tabwidth from the beginning of the line. void Resize(Coord xmin, Coord ymin, Coord xmax, Coord ymax) void Bounds(Coord& xmin, Coord& ymin, Coord& xmax, Coord& ymax) Specify or query the size of the display. Only lines of text that fall completely inside the specified region will be displayed. TextDisplay will not draw on any part of the canvas outside the specified bounds. Conversely, TextDisplay is free to draw on any part of the canvas within the specified bounds. void Draw(Painter*, Canvas*) Specify the painter and canvas to use for drawing operations; the painter specifies the font, colors, and geometric transformation. Draw should be called before performing any operation on the TextDisplay which produces output or requires graphical information, or when there is a possibility that the painter or canvas has changed since the function was last called. void Redraw(Coord left, Coord bottom, Coord right, Coord top) Redraw a specified region of the display. void Scroll(int line, Coord x, Coord y) Scroll the display so that line line is positioned with its upper-left corner at (x, y). There are no restrictions on the argu- ments: it is possible to scroll the display so that no lines are visible. void InsertLinesAfter(int line, int count) void InsertLinesBefore(int line, int count) void DeleteLinesAfter(int line, int count) void DeleteLinesBefore(int line, int count) Insert or delete whole lines of text. Line line is not affected by the operation. Other lines will move up or down to accommodate the changes. Newly inserted lines are blank. The specified line need not refer to an existing line. void InsertText(int line, int index, const char*, int count) void DeleteText(int line, int index, int count) void ReplaceText(int line, const char*, int count) Modify the text within line line. InsertText and DeleteText will cause the following characters on the line to move to accommodate the changes. ReplaceText replaces the entire text of the line. If the specified line is non-existent, a new line will be created. void Style(int line1, int index1, int line2, int index2, int style) void AddStyle(int line1, int index1, int line2, int index2, int style) void RemoveStyle(int line1, int index1, int line2, int index2, int style) Modify the styling of a range of text. Style replaces any existing style; AddStyle adds style style in addition to any existing styles; RemoveStyle removes style style without affecting other existing styles. Styles are specified as any combination of the constants Plain, Boldface, Underlined, and Reversed. void CaretStyle(int style) void Caret(int line, int index) Control the shape and position of a caret. Valid caret styles are currently NoCaret, BarCaret, UnderscoreCaret and OutlineCaret. TextDisplay does not automatically adjust the position of the caret following insertions and deletions. int LineNumber(Coord y) int LineIndex(int line, Coord x) Map x and y display coordinates into line and index text coordinates. LineNumber returns the number of the line that contains the specified vertical position y. LineIndex returns the index into line line that best corresponds to the specified horizontal posi- tion x. Coord Width() Coord Height() Return the width or the height of the text currently displayed by the TextDisplay. Width returns the width of the longest line in the display. Height returns the distance from the top of the topmost line to the bottom of the bottommost line. Note that these dimensions do not necessarily correspond to the TextDisplay's bounds as returned by Bounds. Coord Base(int line) Coord Top(int line) Coord Left(int line, int index) Coord Right(int line, int index) Map line and index text coordinates into x and y display coordinates. The return values define a bounding box for the character specified by line and index. SEE ALSO
Painter(2I), Canvas(2I) InterViews 23 May 1989 TextDisplay(3I)
All times are GMT -4. The time now is 06:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy