Sponsored Content
Top Forums Shell Programming and Scripting How do I strip and add tabbed fields to a long text file? Post 302107781 by saint65 on Tuesday 20th of February 2007 04:37:27 PM
Old 02-20-2007
That works fantastically. Thanks so much, I tried

Code:
awk '
NR > 24 { 
if ( NF == 2 ) 
{ 
	a=$1;b=$2; print "//"$0 ; 
	getline c; print "//"c ; 
	getline;
}
print a "\t" b "\t" c "\t" $0 } ' file

which dumped to screen, I added
Code:
awk '
NR > 24 { 
if ( NF == 2 ) 
{ 
	a=$1;b=$2; print "//"$0 ; 
	getline c; print "//"c ; 
	getline;
}
print a "\t" b "\t" c "\t" $0 } ' file > xyz

to put it into a file.

If i was to add the contents of a second data file that has to be added in sequence, how would i change the numbering?

The first digit (field) is the total count 1-9000 (file 1) the second digit (second field) is group count (just used but not totalled), I need to make 1-9000 (first field) of second data file go from 9001-18000 and so on.

I will be adding contents of file, file1, file2, ... file_n ---> xyz
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need a Help with sort a text file with some fields

Ive got a file called listacdrs with this structure: 01/09/2006 12:13 p.m. 1.046.528 CF0155.DAT 01/09/2006 12:13 p.m. 1.046.528 CF0156.DAT 01/09/2006 12:13 p.m. 1.046.528 CF0157.DAT 01/09/2006 12:13 p.m. 1.046.528 CF0158.DAT 01/09/2006 12:14 p.m. ... (3 Replies)
Discussion started by: alexcol
3 Replies

2. Shell Programming and Scripting

how to strip rows from a text file?

Can an expert kindly write an efficient Linux ksh script that will strip rows with no numbers from a text file? Supposing there are three rows that text file called text.txt : "field1","field2","field3",11,22,33,44 "field1","field2","field3",1,2,3,4 "field1","field2","field3",,,, The... (5 Replies)
Discussion started by: ihot
5 Replies

3. UNIX for Dummies Questions & Answers

extract fields from text file using delimiter!!

Hi All, I am new to unix scripting, please help me in solving this assignment.. I have a scenario, as follows: 1. i have a text file(read1.txt) with the following data sairam,123 kamal,122 etc.. 2. I have to write a unix... (6 Replies)
Discussion started by: G.K.K
6 Replies

4. Shell Programming and Scripting

Getting required fields from a text file in UNIX

My data is something like as shown below. Out of this i want the details of alarms (ex: 1947147711,1947147081......) and the fields( ex :sw=tacmwafabb9:shelf=1:slot=5-2:pport=2) Once i have these details separated, i want the count of these excluding the duplicates. What is the best possible way... (7 Replies)
Discussion started by: rdhanek
7 Replies

5. UNIX and Linux Applications

tabbed text editor without big libraries

I am looking for a tabbed text editor without a big library like gnome, kde, and gtk, I know about gedit, kate with extensions, geany, and bluefish. I would prefer it to be like gedit and be really light weight. So if anyone knows of a text editor that doesn't require those big libraries please let... (3 Replies)
Discussion started by: cokedude
3 Replies

6. Shell Programming and Scripting

Strip some text and format with new delimited

Sample input 19:08:12.172; Cat1 74598; Cat2 1366; Cat3 227; Cat4 389; Cat5 572; Cat6 2228; Cat7 1039; Cat8 25; 19:08:22.173; Cat1 75589; Cat2 1388; Cat3 233; Cat4 393; Cat5 582; Cat6 2253; Cat7 1055; Cat8 25; 19:08:32.173; Cat1 76518; Cat2 1404; Cat3 238; Cat4 397; Cat5 592; Cat6 2270; Cat7... (5 Replies)
Discussion started by: before4
5 Replies

7. Shell Programming and Scripting

Parse file for fields and specific text

I have a file of ~500,000 entries in the following: file.txt chr1 11868 12227 ENSG00000223972.5 . + HAVANA exon . gene_id "ENSG00000223972.5"; transcript_id "ENST00000456328.2"; gene_type "transcribed_unprocessed_pseudogene"; gene_status "KNOWN"; gene_name "DDX11L1"; transcript_type... (17 Replies)
Discussion started by: cmccabe
17 Replies

8. Shell Programming and Scripting

Strip the first record off a file and isolate fields off of it

I have a 2 part question on how to this in unix scripting using kshell or c shell. I have a file described below: 1st record has 2 fields on it every other record has 22 fields on it. Example ABC, email address Detail 1 Detail 2 Detail 3 . . . 1st question is... (4 Replies)
Discussion started by: jclanc8
4 Replies

9. UNIX for Dummies Questions & Answers

Editing long text file

Good morning all, I have a machine running IRIX and I need to edit a text file on the terminal that is literally thousands of lines. Does anyone know the most efficient way to edit portions of files like these? Obviously simply using the vi command isn't going to work since I get a too many lines... (1 Reply)
Discussion started by: James C
1 Replies

10. Shell Programming and Scripting

Tabbed multiple csv files into one single excel file with using shell script not perl

Hi Experts, I am querying backup status results for multiple databases and getting each and every database result in one csv file. so i need to combine all csv files in one excel file with separate tabs. I am not familiar with perl script so i am using shell script. Could anyone please... (4 Replies)
Discussion started by: ramakrk2
4 Replies
HTML::FormFu::Element::Repeatable(3pm)			User Contributed Perl Documentation		    HTML::FormFu::Element::Repeatable(3pm)

NAME
HTML::FormFu::Element::Repeatable - repeatable block element SYNOPSIS
--- elements: - type: Repeatable name: my_rep elements: - name: foo - name: bar Calling "$element->repeat(2)" would result in the following markup: <div> <input name="my_rep.foo_1" type="text" /> <input name="my_rep.bar_1" type="text" /> </div> <div> <input name="my_rep.foo_2" type="text" /> <input name="my_rep.bar_2" type="text" /> </div> Example of constraints: ---- elements: - type: Repeatable name: my_rep elements: - name: id - name: foo constraints: - type: Required when: field: 'my_rep.id' # use full nested-name - name: bar constraints: - type: Equal others: 'my_rep.foo' # use full nested-name DESCRIPTION
Provides a way to extend a form at run-time, by copying and repeating its child elements. The elements intended for copying must be added before "repeat" is called. Although the Repeatable element inherits from Block, it doesn't generate a block tag around all the repeated elements - instead it places each repeat of the elements in a new Block element, which inherits the Repeatable's display settings, such as "attributes" and "tag". For all constraints attached to fields within a Repeatable block which use either others or when containing names of fields within the same Repeatable block, when repeat is called, those names will automatically be updated to the new nested-name for each field (taking into account increment_field_names). METHODS
repeat Arguments: [$count] Return Value: $arrayref_of_new_child_blocks This method creates $count number of copies of the child elements. If no argument $count is provided, it defaults to 1. Note that "$form->process" will call "repeat" automatically to ensure the initial child elements are correctly set up - unless you call "repeat" manually first, in which case the child elements you created will be left untouched (otherwise process would overwrite your changes). Any subsequent call to "repeat" will delete the previously copied elements before creating new copies - this means you cannot make repeated calls to "repeat" within a loop to create more copies. Each copy of the elements returned are contained in a new Block element. For example, calling "$element->repeat(2)" on a Repeatable element containing 2 Text fields would return 2 Block elements, each containing a copy of the 2 Text fields. counter_name Arguments: $name If true, the "query" in HTML::FormFu will be searched during "process" in HTML::FormFu for a parameter with the given name. The value for that parameter will be passed to "repeat", to automatically create the new copies. If "increment_field_names" is true (the default), this is essential: if the elements corresponding to the new fieldnames (foo_1, bar_2, etc.) are not present on the form during "process" in HTML::FormFu, no Processors (Constraints, etc.) will be run on the fields, and their values will not be returned by "params" in HTML::FormFu or "param" in HTML::FormFu. increment_field_names Arguments: $bool Default Value: 1 If true, then all fields will have "_n" appended to their name, where "n" is the "repeatable_count" value. repeatable_count This is set on each new Block element returned by "repeat", starting at number 1. Because this is an 'inherited accessor' available on all elements, it can be used to determine whether any element is a child of a Repeatable element. Only available after repeat has been called. nested_name If the "nested_name" attribute is set, the naming scheme of the Repeatable element's children is switched to add the counter to the repeatable blocks themselves. --- elements: - type: Repeatable nested_name: my_rep elements: - name: foo - name: bar Calling "$element->repeat(2)" would result in the following markup: <div> <input name="my_rep_1.foo" type="text" /> <input name="my_rep_1.bar" type="text" /> </div> <div> <input name="my_rep_2.foo" type="text" /> <input name="my_rep_2.bar" type="text" /> </div> Because this is an 'inherited accessor' available on all elements, it can be used to determine whether any element is a child of a Repeatable element. attributes attrs Any attributes set will be passed to every repeated Block of elements. --- elements: - type: Repeatable name: my_rep attributes: class: rep elements: - name: foo Calling "$element->repeat(2)" would result in the following markup: <div class="rep"> <input name="my_rep.foo_1" type="text" /> </div> <div class="rep"> <input name="my_rep.foo_2" type="text" /> </div> See "attributes" in HTML::FormFu for details. tag The "tag" value will be passed to every repeated Block of elements. --- elements: - type: Repeatable name: my_rep tag: span elements: - name: foo Calling "$element->repeat(2)" would result in the following markup: <span> <input name="my_rep.foo_1" type="text" /> </span> <span> <input name="my_rep.foo_2" type="text" /> </span> See "tag" in HTML::FormFu::Element::Block for details. auto_id As well as the usual subtitutions, any instances of %r will be replaced with the value of "repeatable_count". See "auto_id" in HTML::FormFu::Element::Block for further details. --- elements: - type: Repeatable name: my_rep auto_id: "%n_%r" elements: - name: foo Calling "$element->repeat(2)" would result in the following markup: <div> <input name="my_rep.foo_1" id="foo_1" type="text" /> </div> <div> <input name="my_rep.foo_2" id="foo_2" type="text" /> </div> content Not supported for Repeatable elements - will throw a fatal error if called as a setter. CAVEATS
Unsupported Constraints Note that constraints with an others method do not work correctly within a Repeatable block. Currently, these are: AllOrNone, DependOn, Equal, MinMaxFields, reCAPTCHA. Also, the CallbackOnce constraint won't work within a Repeatable block, as it wouldn't make much sense. SEE ALSO
Is a sub-class of, and inherits methods from HTML::FormFu::Element::Block, HTML::FormFu::Element HTML::FormFu AUTHOR
Carl Franks, "cfranks@cpan.org" LICENSE
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-01-23 HTML::FormFu::Element::Repeatable(3pm)
All times are GMT -4. The time now is 02:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy