Sponsored Content
Top Forums Shell Programming and Scripting retrieved multiple lines on multiple places in a file Post 302167410 by ghostdog74 on Thursday 14th of February 2008 12:09:51 PM
Old 02-14-2008
Quote:
Originally Posted by otheus
In ksh and bash, you can also parse out the first word from the rest:
Code:
case "${line%% *}" in
   first|second|third) echo "$line";;
esac

Code:
while read -r a b
do
 case $a in 
  ....
 esac
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find multiple patterns on multiple lines and concatenate output

I'm trying to parse COBOL code to combine variables into one string. I have two variable names that get literals moved into them and I'd like to use sed, awk, or similar to find these lines and combine the variables into the final component. These variable names are always VAR1 and VAR2. For... (8 Replies)
Discussion started by: wilg0005
8 Replies

2. Shell Programming and Scripting

Logfile parsing with variable, multiple criterias among multiple lines

Hi all I've been working on a bash script parsing through debug/trace files and extracting all lines that relate to some search string. So far, it works pretty well. However, I am challenged by one requirement that is still open. What I want to do: 1) parse through a file and identify all... (3 Replies)
Discussion started by: reminder
3 Replies

3. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

4. Shell Programming and Scripting

Script to find & replace a multiple lines string across multiple php files and subdirectories

Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ? The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories. So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies

5. Shell Programming and Scripting

Awk match multiple columns in multiple lines in single file

Hi, Input 7488 7389 chr1.fa chr1.fa 3546 9887 chr5.fa chr9.fa 7387 7898 chrX.fa chr3.fa 7488 7389 chr21.fa chr3.fa 7488 7389 chr1.fa chr1.fa 3546 9887 chr9.fa chr5.fa 7898 7387 chrX.fa chr3.fa Desired Output 7488 7389 chr1.fa chr1.fa 2 3546 9887 chr5.fa chr9.fa 2... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

6. Shell Programming and Scripting

Grep from multiple patterns multiple file multiple output

Hi, I want to grep multiple patterns from multiple files and save to multiple outputs. As of now its outputting all to the same file when I use this command. Input : 108 files to check for 390 patterns to check for. output I need to 108 files with the searched patterns. Xargs -I {} grep... (3 Replies)
Discussion started by: Diya123
3 Replies

7. Shell Programming and Scripting

Reading multiple values from multiple lines and columns and setting them to unique variables.

Hello, I would like to ask for help with csh script. An example of an input in .txt file is below, the number of lines varies from file to file and I have 2 or 3 columns with values. I would like to read all the values (probably one by one) and set them to independent unique variables that... (7 Replies)
Discussion started by: FMMOLA
7 Replies

8. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies

9. Shell Programming and Scripting

Removing carriage returns from multiple lines in multiple files of different number of columns

Hello Gurus, I have a multiple pipe separated files which have records going over multiple Lines. End of line separator is \n and records going over multiple lines have <CR> as separator. below is example from one file. 1|ABC DEF|100|10 2|PQ RS T|200|20 3| UVWXYZ|300|30 4| GHIJKL|400|40... (7 Replies)
Discussion started by: dJHa
7 Replies

10. Shell Programming and Scripting

Read a string and add " at multiple places

Hi All, I have below text, i want to add " in it, please advise. FORD MOTOR COMPANY FORD COMPONENT SALES, LLC Mazda Motor Manufacturing de Mexico, S.A. de C.V. Desired: "FORD MOTOR COMPANY" "FORD COMPONENT SALES, LLC"" Mazda Motor Manufacturing de Mexico, S.A. de C.V." edit by bakunin:... (2 Replies)
Discussion started by: Amit Saroha
2 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 11:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy