Sponsored Content
Top Forums Shell Programming and Scripting Extract multiple repeated data from a text file Post 302306842 by Franklin52 on Tuesday 14th of April 2009 02:40:55 AM
Old 04-14-2009
Quote:
Originally Posted by Whiteboard
Please explain your code

Thanks
white
Code:
awk '/^ST/{++i}{print > "file" i}' textfile

Code:
/^ST/{++i}

If the line begins with ST increase the variable i. The first time the name of the output file is file1, the next time the line begins with ST the name of the output file becomes file2 and so forth.

Code:
{print > "file" i}

Print the line to the file "file"i.

Regards
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to extract data from a text file

Hello All, Is there an easy way to extract data from a text file? The text file is actually a dump of a 2 page report with 6 columns and 122 lines. Example is Report Tile Type Product 1 Product 2 Product 3 Product 4... (1 Reply)
Discussion started by: negixx
1 Replies

2. Shell Programming and Scripting

Delete repeated word in text file

Hi expert, I am using C shell. And i trying to delete repeated word. Example file.txt: BLUE YELLOW RED VIOLET RED RED BLUE WHITE YELLOW BLACK and i wan store the output into a new file: BLUE (6 Replies)
Discussion started by: vincyoxy
6 Replies

3. UNIX for Dummies Questions & Answers

Help please, extract multiple lines from a text file

Hi all, I need to extract lines between the lines 'RD' and 'QA' from a text file (following). there are more that one of such pattern in the file and I need to extract all of them. however, the number of lines between them is varied in the file. Therefore, I can not just use 'grep -A' command.... (6 Replies)
Discussion started by: johnshembb
6 Replies

4. UNIX for Dummies Questions & Answers

AWK, extract data from multiple files

Hi, I'm using AWK to try to extract data from multiple files (*.txt). The script should look for a flag that occurs at a specific position in each file and it should return the data to the right of that flag. I should end up with one line for each file, each containing 3 columns:... (8 Replies)
Discussion started by: Liverpaul09
8 Replies

5. Shell Programming and Scripting

How to find repeated string in a text file

I have a text file where I need to find the string = ST*850* This string is repetaed several times in the file, so I need to know how many times it appears in the file, this is the text files: ISA*00* *00* *08*925485USNR *ZZ*IMSALADDERSP... (13 Replies)
Discussion started by: cucosss
13 Replies

6. Shell Programming and Scripting

regular expression with shell script to extract data out of a text file

hi i am trying to extract some specific data out of a text file using regular expressions with shell script that is using a multiline grep .. and the tool i am using is pcregrep so that i can get compatibility with perl's regular expressions for a sample data like this, i am trying to grab... (6 Replies)
Discussion started by: vemkiran
6 Replies

7. UNIX for Dummies Questions & Answers

Extract common data out of multiple files

I am trying to extract common list of Organisms from different files For example I took 3 files and showed expected result. In real I have more than 1000 files. I am aware about the useful use of awk and grep but unaware in depth so need guidance regarding it. I want to use awk/ grep/ cut/... (7 Replies)
Discussion started by: macmath
7 Replies

8. Shell Programming and Scripting

Extract data in tabular format from multiple files

Hi, I have directory with multiple files from which i need to extract portion of specif lines and insert it in a new file, the new file will contain a separate columns for each file data. Example: I need to extract Value_1 & Value_3 from all files and insert in output file as below: ... (2 Replies)
Discussion started by: belalr
2 Replies

9. Shell Programming and Scripting

awk used to extract data between text

Hello all, I have a file (filename.txt) with some data (in two columns X and Y) which looks like this: ########## 'Header1' 'Sub-header1' X Y xxxx.xx yyyy.yyy xxxx.xx yyyy.yyy .... ... 'Sub-header2' X Y xxxx.xx ... (7 Replies)
Discussion started by: jaldo0805
7 Replies

10. UNIX for Beginners Questions & Answers

Shell - Read a text file with two words and extract data

hi I made this simple script to extract data and pretty much is a list and would like to extract data of two words separated by commas and I would like to make a new text file that would list these extracted data into a list and each in a new line. Example that worked for me with text file... (5 Replies)
Discussion started by: dandaryll
5 Replies
OGMDEMUX(1)							   User Commands						       OGMDEMUX(1)

NAME
ogmdemux - Extract streams from OGG/OGM files into separate files SYNOPSIS
ogmdemux [options] inname DESCRIPTION
This program extracts all or only some streams from an OGM and writes them to separate files. inname Use 'inname' as the source. -o, --output out Use 'out' as the base for destination file names. '-v1', '-v2', '-a1', '-t1'... will be appended to this name. Default: use 'inname'. -a, --astream n Extract specified audio stream. Can be used more than once. Default: extract all streams. -d, --vstream n Extract specified video stream. Can be used more than once. Default: extract all streams. -t, --tstream n Extract specified text stream. Can be used more than once. Default: extract all streams. -na, --noaudio Don't extract any audio streams. -nv, --novideo Don't extract any video streams. -nt, --notext Don't extract any text streams. Default: extract all streams. -r, --raw Extract the raw streams only. Default: extract to useful formats (AVI, WAV, OGG, SRT...). -v, --verbose Increase verbosity. -h, --help Show this help. -V, --version Show version number. NOTES
What works: * Extraction of the following formats is fully supported including writing the stream contents to useful container formats: video -> AVI Vorbis -> OGG/Vorbis PCM -> WAV text -> text files (SRT subtitle format) * All other audio streams (MP3, AC3) are just copied 1:1 into output files. MP3 and AC3 files should be usable. Others might not. What not works: * Headers created by older OggDS (DirectShow) filter versions are not supported (and probably never will be). AUTHOR
ogmdemux was written by Moritz Bunkus <moritz@bunkus.org>. SEE ALSO
ogmmerge(1), ogmsplit(1), ogminfo(1), ogmcat(1), dvdxchap(1) WWW
The newest version can always be found at <http://www.bunkus.org/videotools/ogmtools/> <http://www.bunkus.org/videotools/ogmtools/> ogmdemux v1.5 November 2004 OGMDEMUX(1)
All times are GMT -4. The time now is 09:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy