Sponsored Content
Top Forums Shell Programming and Scripting How to extract some parts of a file to create some outfile Post 302314450 by ghostdog74 on Friday 8th of May 2009 10:26:48 AM
Old 05-08-2009
Quote:
Originally Posted by iammitra
Hallo ghostdog74,
Thanks for your reply. But I am sorry to say that I forgot to mention : in my input file there are not always only 6 lines. I just copied some lines.. This lines varies from 100 to 200. So it is necessary for the program to read +++++++++End.

Thanks a lot,
Mitra.
well, i am not sure i get you, but i see other solutions include "End', therefore if you are sure that ++++++++ is not unique, you can add "End"
Code:
....
if line.startswith("+++++++++++End"): 
....

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extract columns from 2 different files and create new file

Hi All, I have 2 issues while working with file. 1. I have 2 delimited(~) files. I want to extract column numbner 3 from file1 and column number 8 from file2 and paste it into file3. I have tried using cut, but not able to get answer. 2. i have 2 filxed-width file. I wanted to do same... (1 Reply)
Discussion started by: Amit.Sagpariya
1 Replies

2. Shell Programming and Scripting

Extract date from filename and create a new file

Hi, i have a filename CRED20102009.txt in a server 20102009 is the date of the file ddmmaaaa format the complete route is /dprod/informatica/Fuentes/CRED20102009.csv i want to extract the date to create a new file named Parameters.txt I need to create Parameters.txt with this... (6 Replies)
Discussion started by: angel1001
6 Replies

3. Shell Programming and Scripting

Create shell script to extract unique information from one file to a new file.

Hi to all, I got this content/pattern from file http.log.20110808.gz mail1 httpd: Account Notice: close igchung@abc.com 2011/8/7 7:37:36 0:00:03 0 0 1 mail1 httpd: Account Information: login sastria9@abc.com proxy sid=gFp4DLm5HnU mail1 httpd: Account Notice: close sastria9@abc.com... (16 Replies)
Discussion started by: Mr_47
16 Replies

4. Shell Programming and Scripting

awk? create similarity matrix by calculating overlaps between sets comprising of individual parts

Hi everyone I am very new at awk and to me the task I need to get done is very very challenging... Nevertheless, after admiring how fast and elegant issues are being solved here I am sure this is my best chance. I have a 2D data file (input file is a plain tab-delimited text file). The first... (1 Reply)
Discussion started by: stonemonkey
1 Replies

5. Shell Programming and Scripting

extract certain parts from a file

I have a logfile from which i need to extract certain pattern based on the time but the problem here is the time is not same for all days. Input file: Mon 12:34:56 abvjingjgg Mon 12:34:57 ofjhjgjhgh . . . Mon 22:30:00 kkfng . . . Mon 23:12:23 kjgsdafhkljf . . . Tue 01:04:54... (8 Replies)
Discussion started by: gpk_newbie
8 Replies

6. Shell Programming and Scripting

Extract Parts of File

Hello All, I have a file like this Define schema flat_file_schema ( a varchar(20) ,b varchar(30) ,c varchar(40) ); (Insert into table ( a ,b ,c ) values ( 1 ,2 ,3 ); (4 Replies)
Discussion started by: nnani
4 Replies

7. Shell Programming and Scripting

Incrementing parts of ten digits number by parts

I have number in file which contains date and serial number: 2013101000. The last two digits are serial number (00). So maximum of serial number is 100. After reaching 100 it becomes 00 with incrementing 10 which is day with max 31. after reaching 31 it becomes 00 and increments 10... (31 Replies)
Discussion started by: Natalie
31 Replies

8. Solaris

Solaris 10 error "-sh: /tmp/outfile: cannot create"

Hello, Each time a user log on to host, they receive below error: -sh: /tmp/outfile: cannot create Example: $ ssh host user@host's password: Last login: Fri Dec 4 08:17:28 2015 from client.ref |-----------------------------------------------------------------| -sh:... (2 Replies)
Discussion started by: feroccimx
2 Replies

9. Shell Programming and Scripting

Extract parts of the line

I have a long list of lines in a txt file which i'm only interested to extract the list of domains like the colored ones. domain.com domain.com/page codes $.09 domain.org domain.org/page2/ codes $0.10 domain.net domain.net/page03 codes $0.05 domain.info ... (3 Replies)
Discussion started by: garfish
3 Replies

10. UNIX for Beginners Questions & Answers

TCL script to extract the file name and then create two independent list

I am having one problem as stated below Problem Description I am having some "sv" extension files , I am using "glob" to extract the matching files , Now in these matching files , I need to split them and extract the elements and create different lists. For example set files This... (1 Reply)
Discussion started by: kshitij
1 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 03:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy