Sponsored Content
Top Forums Shell Programming and Scripting How to extract a text portion from a file Post 302332440 by ejazs0 on Thursday 9th of July 2009 06:29:51 AM
Old 07-09-2009
How to extract a text portion from a file

Can some one help me with shell script to extract a text block between two known strings.

The given input file is as below:

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

output file should contain

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

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
SDFGET(1)						User Contributed Perl Documentation						 SDFGET(1)

NAME
sdfget - Documentation Extraction Utility PURPOSE
sdfget extracts documentation embedded in source code. USAGE
usage : sdfget [-h[help]] [-o[out_ext]] [-l[log_ext]] [-O[out_dir]] [-f formatting_filename] [-g[get_rule]] [-r[rpt_file]] [-s scope] [-i] [-v[verbose]] file ... purpose: extract documentation embedded in source code version: 2.000 (SDF 2.001) The options are: Option Description -h display help on options -o output file extension -l log file extension -O output to input file's (or explicit) directory -f filename to use when formatting the output -g rule to use to get documentation -r report file -s scope of documentation to be extracted -i only output lines not extracted -v verbose mode DESCRIPTION
The -h option provides help. If it is specified without a parameter, a brief description of each option is displayed. To display the attributes for an option, specify the option letter as a parameter. By default, generated output goes to standard output. To direct output to a file per input file, use the -o option to specify an extension for output files. If the -o option is specified without a parameter, an extension of out is assumed. Likewise, error messages go to standard error by default. Use the -l option to create a log file per input file. If the -l option is specified without a parameter, an extension of log is assumed. By default, generated output and log files are created in the current directory. Use the -O option to specify an explicit output directory. If the -O option is specified without a parameter, the input file's directory is used. The -f option can be used to specify a filename to use when formatting the output. This is useful when the text is coming from the standard input stream. The get-rule nominates the formatting of the embedded documentation to be extracted. All currently defined get-rules assume the documentation is in comment blocks in one of the following formats: >>section_title1:: text of section 1, line 1 text of section 1, line .. >>section_title2:: text of section 2, line 1 text of section 2, line .. >>END:: >>section_title3:: text of section 3 The first form is most commonly used. In this format, the text in a section extends until the end of the current "comment block" or the start of the next section, whichever comes first. The second form (i.e. explicitly specifying where the section ends) is useful if you wish to add some normal comments (i.e. non-documentation) which you do not want extracted. If the text is short, the third form can be used. Regardless of the format, if a section is found which is already defined, the text of the section is concatenated onto the existing text. This permits the documentation for each entity to be specified immediately above where it is defined in the source code. The -g option specifies the get-rule to use. The available get-rules differ on the prefix expected at the front of each line as shown below. Rule Prefix perl # cpp // c * or /* fortran c (with 5 preceding spaces) eiffel -- bat rem Within C code, a trailing space is required after the characters above. For other languages, a trailing space is optional. Within FORTRAN code, the "c" character must be preceded by exactly 5 spaces. For other languages, zero or more whitespace characters are permitted before the characters above. For example, embedded documentation within C code looks like: /* >>Purpose:: * This library provides a high level interface * to commonly used network services. */ If the -g option is not specified, perl is the default get-rule. If the -g option is specified without a parameter, the extension in lowercase of the filename (or the formatting filename if the text is coming from standard input) is used to guess the get_rule as shown below. Rule Extensions cpp cpp, c++, cc, hpp, hpp, h, java, idl c c fortran fortran, for, f77, f eiffel eiffel, ada bat bat, cmd A report filename can be specified using the -r option. If the name doesn't include an extension, sdg is assumed. Reports provide a mechanism for: o selectively extracting sections, and o rudimentary reformatting (e.g. to SDF) If no report is specified, all sections are output in the following format: section_title1 section_text1 section_title2 section_text2 If -r is specified on its own, default.sdg is assumed. This report selects the set of sections (within the SDF documentation standards) which form the user documentation and formats them into SDF. Details on the report format are specified below. Reports are searched for in the current directory, then in the stdlib directory within SDF's library directory. The -s option can be used to specify the scope of the documentation to be extracted. (This is an experimental feature and may change so most users should avoid using it.) The -i option outputs only those lines which the get-rule did not match. This option is useful for extracting non-documentation from a file to give just the code. Note: The -r option is ignored if -i is specified. The -v option enables verbose mode. This is useful for seeing which rule is being used for each file. EXAMPLES
To extract the user documentation from a SDF application written in C++ (xyz, say) and save it into xyz.sdf: sdfget -gcpp -r -osdf xyz.cpp LIMITATIONS AND FUTURE DIRECTIONS
It would be nicer if the get-rule was always guessed from the filename extension but changing the default from perl could break existing scripts. Therefore, get-rule guessing must be explicitly enabled by specifging the -g option without a parameter. perl v5.12.4 2011-11-09 SDFGET(1)
All times are GMT -4. The time now is 06:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy