Sponsored Content
Top Forums Shell Programming and Scripting help extracting text from file Post 302674977 by elixir_sinari on Saturday 21st of July 2012 03:46:14 AM
Old 07-21-2012
Code:
awk '
/^552/{print $3, $4, $5}
/^554/{
printf("%s %s ",substr($1,6,6),substr($1,length($1)-3))
for(i=2;i<=NF;i++)
 printf("%s %s ",substr($i,1,6),substr($i,length($i)-3))
print ""
}' inputfile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting data from text file based on configuration set in config file

Hi , a:) i have configuration file with pattren <Range start no>,<Range end no>,<type of records to be extracted from the data file>,<name of the file to store output> eg: myfile.confg 9899000000,9899999999,DATA,b.dat 9899000000,9899999999,SMS,a.dat b:) Stucture of my data file is... (3 Replies)
Discussion started by: suparnbector
3 Replies

2. Shell Programming and Scripting

extracting unique lines from text file

I have a file with 14million lines and I would like to extract all the unique lines from the file into another text file. For example: Contents of file1 happy sad smile happy funny sad I want to run a command against file one that only returns the unique lines (ie 1 line for happy... (3 Replies)
Discussion started by: soliberus
3 Replies

3. Shell Programming and Scripting

Extracting a line in a text file

If my file looks like this…. 10 20 30 and I want to take each line individually and put it in a variable so it can be read later in it's on individual test statement, how can I do that? I guess what I'm asking is how can I extract each line individually. Thanks (5 Replies)
Discussion started by: terryporter51
5 Replies

4. Shell Programming and Scripting

Extracting specific text from a file

Dear All, I have to extract a a few lines from a log file and I know the starting String and end string(WHich is same ). Is there any simplere way using sed - awk. e.g. from the following file -------------------------------------- Some text Date: 21 Oct 2008 Text to be extracted... (8 Replies)
Discussion started by: rahulkav
8 Replies

5. UNIX for Dummies Questions & Answers

extracting text and reusing the text to rename file

Hi, I have some ps files where I want to ectract/copy a certain number from and use that number to rename the ps file. eg: 'file.ps' contains following text: 14 (09 01 932688 0)t the text can be variable, the only fixed element is the '14 ('. The problem is that the fixed element can appear... (7 Replies)
Discussion started by: JohnDS
7 Replies

6. Shell Programming and Scripting

Extracting specific characters from a text file

I'm extremely new to scripting and linux in general, so please bear with me. The class I'm taking gives virtually no instruction at all, and so I'm trying to learn everything off the web. Anyway, I'm trying to extract characters that follow after a specific pattern ( '<B><FONT FACE="Arial">' ) but... (3 Replies)
Discussion started by: livos23
3 Replies

7. Shell Programming and Scripting

extracting part of a text file

Hi guys So I have a very large log file where each event is logged along with the time that it occurred. So for e.g. The contents of the file look like: ... 12:00:07 event 0 happened. 12:01:01 event 1 happened. 12:01:05 event 2 happened. 12:01:30 event 3 happened. 12:02:01 event 4... (10 Replies)
Discussion started by: alinaqvi90
10 Replies

8. UNIX for Dummies Questions & Answers

Extracting the last column of a text file

I would like to extract the last column of a text file but different rows of the text file have different numbers of columns. How do I go about doing that? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

9. UNIX for Dummies Questions & Answers

Extracting lines from a text file based on another text file with line numbers

Hi, I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

10. Shell Programming and Scripting

Extracting and copying text from one file to another

Helooo, So I have a .fasta file (a text file with sequence data) which looks like this, with just over 3 million lines of data. >TCONS_00000001 gene=XLOC_000001 AATTGTGGTGAAATGACTTCTGTTAACGGAGACATCGATGATTGTTGTTACTATTTGTTCTCAGGATTCA... (8 Replies)
Discussion started by: 4galaxy7
8 Replies
Affixes(3pm)						User Contributed Perl Documentation					      Affixes(3pm)

NAME
Text::Affixes - Prefixes and suffixes analisys of text SYNOPSIS
use Text::Affixes; my $text = "Hello, world. Hello, big world."; my $prefixes = get_prefixes($text); # $prefixes now holds # { # 3 => { # 'Hel' => 2, # 'wor' => 2, # } # } # or $prefixes = get_prefixes({min => 1, max => 2},$text); # $prefixes now holds # { # 1 => { # 'H' => 2, # 'w' => 2, # 'b' => 1, # }, # 2 => { # 'He' => 2, # 'wo' => 2, # 'bi' => 1, # } # } # the use for get_suffixes is similar DESCRIPTION
Provides methods for prefixe and suffix analisys of text. METHODS
get_prefixes Extracts prefixes from text. You can specify the minimum and maximum number of characters of prefixes you want. Returns a reference to a hash, where the specified limits are mapped in hashes; each of those hashes maps every prefix in the text into the number of times it was found. By default, both minimum and maximum limits are 3. If the minimum limit is greater than the lower one, an empty hash is returned. A prefix is considered to be a sequence of word characters (w) in the beginning of a word (that is, after a word boundary) that does not reach the end of the word ("regular expressionly", a prefix is the $1 of /(w+)w/). # extracting prefixes of size 3 $prefixes = get_prefixes( $text ); # extracting prefixes of sizes 2 and 3 $prefixes = get_prefixes( {min => 2}, $text ); # extracting prefixes of sizes 3 and 4 $prefixes = get_prefixes( {max => 4}, $text ); # extracting prefixes of sizes 2, 3 and 4 $prefixes = get_prefixes( {min => 2, max=> 4}, $text); get_suffixes The get_suffixes function is similar to the get_prefixes one. You should read the documentation for that one and than come back to this point. A suffix is considered to be a sequence of word characters (w) in the end of a word (that is, before a word boundary) that does not start at the beginning of the word ("regular expressionly" speaking, a prefix is the $1 of /w(w+)/). # extracting suffixes of size 3 $suffixes = get_suffixes( $text ); # extracting suffixes of sizes 2 and 3 $suffixes = get_suffixes( {min => 2}, $text ); # extracting suffixes of sizes 3 and 4 $suffixes = get_suffixes( {max => 4}, $text ); # extracting suffixes of sizes 2, 3 and 4 $suffixes = get_suffixes( {min => 2, max=> 4}, $text); OPTIONS
Apart from deciding on a minimum and maximum size for prefixes or suffixes, you can also decide on some configuration options. exclude_numbers Set to 0 if you consider numbers as part of words. Default value is 1. # this get_suffixes( {min => 1, max => 1, exclude_numbers => 0}, "Hello, but w8" ); # returns this: { 1 => { 'o' => 1, 't' => 1, '8' => 1 } } lowercase Set to 1 to extract all prefixes in lowercase mode. Default value is 0. ATTENTION: This does not mean that prefixes with uppercased characters won't be extracted. It means they will be extracted after being lowercased. # this... get_prefixes( {min => 2, max => 2, lowercase => 1}, "Hello, hello"); # returns this: { 2 => { 'he' => 2 } } TO DO
o Make it more efficient (use C for that) AUTHOR
Jose Castro, "<cog@cpan.org>" COPYRIGHT &; LICENSE Copyright 2004 Jose Castro, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2005-11-19 Affixes(3pm)
All times are GMT -4. The time now is 06:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy