Sponsored Content
Top Forums Shell Programming and Scripting using awk to extract text between two constant strings Post 302164355 by mjoshi on Monday 4th of February 2008 03:12:18 PM
Old 02-04-2008
In other words what i want to do is the following:

if row number "i" = /SUN> read db @cmpd unit 60/
and row number "i+4" = /tabint>ERROR:/
print row number "i+1"
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using AWK how to extract text between two same strings

I have a file like: myfile.txt it is easy to learn awk and begin awk scripting and awk has got many features awk is a powerful text processing tool Now i want to get the text between first awk and immediate awk not the third awk . How to get it ? its urgent pls help me and file is unevenly... (2 Replies)
Discussion started by: santosh1234
2 Replies

2. UNIX for Dummies Questions & Answers

Using awk/sed to extract text between Strings

Dear Unix Gurus, I've got a data file with a few hundred lines (see truncated sample)... BEGIN_SCAN1 TASK_NAME=LA48 PDD Profiles PROGRAM=ArrayScan 1.00 21.220E+00 2.00 21.280E+00 END_DATA END_SCAN1 BEGIN_SCAN2 TASK_NAME=LA48 PDD Profiles 194.00 2.1870E+00 ... (5 Replies)
Discussion started by: tintin72
5 Replies

3. Shell Programming and Scripting

AWK: How to extract text lines between two strings

Hi. I have a text test1.txt file like:Receipt Line1 Line2 Line3 End Receipt Line4 Line5 Line6 Canceled Receipt Line7 Line8 Line9 End (9 Replies)
Discussion started by: TQ3
9 Replies

4. Shell Programming and Scripting

choose random text between constant string.. using awk?

Hallo I have maybe a little bit advanced request.... I need to choose one random part betwen %.... so i have this.. % text1 text1 text1 text1 text1 text1 text1 text1 text1 % text2 text2 text2 text2 text2 % text3 text3 text3 tetx3 % this choose text between % awk ' /%/... (8 Replies)
Discussion started by: sandwich
8 Replies

5. UNIX for Advanced & Expert Users

bash/grep/awk/sed: How to extract every appearance of text between two specific strings

I have a text wich looks like this: clid=2 cid=6 client_database_id=35 client_nickname=Peter client_type=0|clid=3 cid=22 client_database_id=57 client_nickname=Paul client_type=0|clid=5 cid=22 client_database_id=7 client_nickname=Mary client_type=0|clid=6 cid=22 client_database_id=6... (3 Replies)
Discussion started by: Pioneer1976
3 Replies

6. Shell Programming and Scripting

Extract text between two specified "constant" texts using awk

Hi All, From the title you may know that this question has been asked several times and I have done lot of Googling on this. I have a Wikipedia dump file in XML format. All the contents are in one XML file i.e. all different topics have been put in one XML file. Now I need to separate them and... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

7. Shell Programming and Scripting

How to Extract text between two strings?

Hi, I want to extract some text between two strings in a line i am using following command i.e; awk '/-string1/,/-string2/' filename contents of file is--- line1 line2 aaa -bbb -ccc -string1 c,d,e -string2 line4 but it is showing complete line which is having searched strings. aaa... (19 Replies)
Discussion started by: emresearch
19 Replies

8. Shell Programming and Scripting

Extract text between two strings

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)
Discussion started by: chrispaz81
4 Replies

9. Shell Programming and Scripting

Extracting text between two constant strings

Hi All, I have a file whose common patter is like this: .I 1 .U 87049087 .S Some text here too .M This is a text .T Some another text here .P Name of the book .W Some lines of more text. This text needs to be extracted. .A more text goes here too .I 2 (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

10. Shell Programming and Scripting

Extract text between two strings

Hi, I have a text like these: ECHO "BEGGINING THE SHELL....." MV FILE1 > FILE2 UNIQ_ID=${1} PARTITION_1=`${PL}/Q${CON}.KSH "SELECT ....." PARTITION_2=`${PL}/Q${CON}.KSH "SELECT ........" ${PL}/Q${CON}.KSH "CREATE ...." IF .... ....... I would like to extract only text that only... (4 Replies)
Discussion started by: mierdatuti
4 Replies
XSTR(1) 						    BSD General Commands Manual 						   XSTR(1)

NAME
xstr -- extract strings from C programs to implement shared strings SYNOPSIS
xstr [-cv] [-l array] [-] [file ...] DESCRIPTION
xstr maintains a file strings into which strings in component parts of a large program are hashed. These strings are replaced with refer- ences to this common area. This serves to implement shared constant strings, most useful if they are also read-only. Available options: - xstr reads from the standard input. -c xstr will extract the strings from the C source file or the standard input (-), replacing string references by expressions of the form (&xstr[number]) for some number. An appropriate declaration of xstr is prepended to the file. The resulting C text is placed in the file x.c, to then be compiled. The strings from this file are placed in the strings data base if they are not there already. Repeated strings and strings which are suffixes of existing strings do not cause changes to the data base. -l array Specify the named array in program references to abstracted strings. The default array name is xstr. -v Be verbose. After all components of a large program have been compiled, a file xs.c declaring the common xstr space can be created by a command of the form: $ xstr The file xs.c should then be compiled and loaded with the rest of the program. If possible, the array can be made read-only (shared) saving space and swap overhead. xstr can also be used on a single file. The following command creates files x.c and xs.c as before, without using or affecting any strings file in the same directory: $ xstr name It may be useful to run xstr after the C preprocessor if any macro definitions yield strings or if there is conditional code which contains strings which may not, in fact, be needed. An appropriate command sequence for running xstr after the C preprocessor is: $ cc -E name.c | xstr -c - $ cc -c x.c $ mv x.o name.o xstr does not touch the file strings unless new items are added, thus make(1) can avoid remaking xs.o unless truly necessary. FILES
strings Data base of strings x.c Massaged C source xs.c C source for definition of array `xstr' /tmp/xs* Temp file when `xstr name' doesn't touch strings SEE ALSO
mkstr(1) HISTORY
The xstr command appeared in 3.0BSD. BUGS
If a string is a suffix of another string in the data base, but the shorter string is seen first by xstr both strings will be placed in the data base, when just placing the longer one there will do. xstr does not parse the file properly so it does not know not to process: char var[] = "const"; into: char var[] = (&xstr[N]); These must be changed manually into an appropriate initialization for the string, or use the following ugly hack. Also, xstr cannot initialize structures and unions that contain strings. Those can be fixed by changing from: struct foo { int i; char buf[10]; } = { 1, "foo" }; to: struct foo { int i; char buf[10]; } = { 1, { 'f', 'o', 'o', '' } }; The real problem in both cases above is that the compiler knows the size of the literal constant so that it can perform the initialization required, but when xstr changes the literal string to a pointer reference, the size information is lost. It would require a real parser to do this right, so the obvious solution is to fix the program manually to compile, or even better rely on the compiler and the linker to merge strings appropriately. Finally, xstr is not very useful these days because most of the string merging is done automatically by the compiler and the linker, provided that the strings are identical and read-only. BSD
July 23, 2004 BSD
All times are GMT -4. The time now is 05:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy