Sponsored Content
Top Forums Shell Programming and Scripting SED/AWK to edit/add field values in a record Post 302669969 by Scott on Wednesday 11th of July 2012 12:55:49 PM
Old 07-11-2012
Perhaps from this, you can fathom the other parts?

Code:
$ awk 'BEGIN {FS=OFS=","} {$3=$1 "00"; $4=...} 1' file
3538,,353800,,,,ID,ID1,,,,,,,,,,,

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Conditional edit for a field using sed

Hi I want to repalce a field in a txt file on solaris with say 100 records and each record having a total of 10 fields separated by a ~ . based on the following condition the record should be edited or else the record should be written as it is to a if the seventh field is 'XX' and if... (2 Replies)
Discussion started by: acharania2011
2 Replies

2. UNIX for Advanced & Expert Users

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Discussion started by: yerruhari
1 Replies

3. UNIX for Dummies Questions & Answers

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Discussion started by: yerruhari
1 Replies

4. Shell Programming and Scripting

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (3 Replies)
Discussion started by: yerruhari
3 Replies

5. Shell Programming and Scripting

awk or sed to add field in a text file

Hi there, I have a csv file with some columns comma sepated like this : 4502-17,PETER,ITA2,LEGUE,92,ME - HALF,23/05/10 15:00 4502-18,CARL,ITA2,LEGUE,96,ME - HALF,20/01/09 14:00 4502-19,OTTO,ITA2,LEGUE,97,ME - MARY,23/05/10 15:00 As you can see the column n. 7 is a timestamp column, I need... (23 Replies)
Discussion started by: capnino
23 Replies

6. Shell Programming and Scripting

edit field using sed or awk

please help me to edit the second field using awk or sed i have input file below aa1001 000001 bb1002 000002 cc1003 000003 so i want the output file like below aa1001 01 bb1002 02 cc1003 03 (38 Replies)
Discussion started by: zulabc
38 Replies

7. Shell Programming and Scripting

Splitting record into multiple records by appending values from an input field (AWK)

Hello, For the input file, I am trying to split those records which have multiple values seperated by '|' in the last input field, into multiple records and each record corresponds to the common input fields + one of the value from the last field. I was trying with an example on this forum... (4 Replies)
Discussion started by: imtiaz99
4 Replies

8. Shell Programming and Scripting

Save awk record field in bourne shell variable

Hello, I am trying to write a shell script that maintains the health of the passwd file. The goal is to check for duplicate usernames, UID's etc. I am able to find and sort out the UID and login names via awk (which I would like to use), but I can't figure out how to save the record field into a... (1 Reply)
Discussion started by: Learn4Life
1 Replies

9. Shell Programming and Scripting

Require original field position after sorting the values in a record

Dear Team, Can any body help me out to get the filed position of the records post sorting using AWK programming. Thanks in advance Example Input: StudentID col-1 col-2 col-3 col-4 1234 14 10 12 13 1235 10 11 12 13 1236 13 12 11 10 ... (3 Replies)
Discussion started by: Srinivasa Reddy
3 Replies

10. Shell Programming and Scripting

Insert field values in a record using awk command

Hi Friends, Below is my input file with "|" (pipe) as filed delimiter: My Input File: HDR|F1|F2||||F6|F7 I want to inser values in the record for field 4 and field 5. Expected output HDR|F1|F2||F4|F5|F6|F7 I am able to append the string to the end of the record, but not in between the... (3 Replies)
Discussion started by: Ajay Venkatesan
3 Replies
MooseX::Declare::Context(3pm)				User Contributed Perl Documentation			     MooseX::Declare::Context(3pm)

NAME
MooseX::Declare::Context - Per-keyword declaration context DESCRIPTION
This is not a subclass of Devel::Declare::Context::Simple, but it will delegate all default methods and extend it with some attributes and methods of its own. A context object will be instanciated for every keyword that is handled by MooseX::Declare. If handlers want to communicate with other handlers (for example handlers that will only be setup inside a namespace block) it must do this via the generated code. In addition to all the methods documented here, all methods from Devel::Declare::Context::Simple are available and will be delegated to an internally stored instance of it. ATTRIBUTES
caller_file A required "Str" containing the file the keyword was encountered in. preamble_code_parts An "ArrayRef" of "CodePart"s that will be used as preamble. A preamble in this context means the beginning of the generated code. scope_code_parts These parts will come before the actual body and after the "preamble_code_parts". It is an "ArrayRef" of "CodePart"s. cleanup_code_parts An "ArrayRef" of "CodePart"s that will not be directly inserted into the code, but instead be installed in a handler that will run at the end of the scope so you can do namespace cleanups and such. stack An "ArrayRef" that contains the stack of handlers. A keyword that was only setup inside a scoped block will have the blockhandler be put in the stack. METHODS
add_preamble_code_parts(CodePart @parts) Object->add_preamble_code_parts (CodeRef @parts) See "add_cleanup_code_parts". add_scope_code_parts(CodePart @parts) Object->add_scope_code_parts (CodeRef @parts) See "add_cleanup_code_parts". add_cleanup_code_parts(CodePart @parts) Object->add_cleanup_code_parts (CodeRef @parts) For these three methods please look at the corresponding *_code_parts attribute in the list above. These methods are merely convenience methods that allow adding entries to the code part containers. inject_code_parts_here True Object->inject_code_parts_here (CodePart @parts) Will inject the passed "CodePart"s at the current position in the code. peek_next_char Str Object->peek_next_char () Will return the next char without stripping it from the stream. inject_code_parts Object->inject_code_parts ( Bool :$inject_cleanup_code_parts, CodeRef :$missing_block_handler ) This will inject the code parts from the attributes above at the current position. The preamble and scope code parts will be inserted first. Then then call to the cleanup code will be injected, unless the options contain a key named "inject_cleanup_code_parts" with a false value. The "inject_if_block" method will be called if the next char is a "{" indicating a following block. If it is not a block, but a semi-colon is found and the options contained a "missing_block_handler" key was passed, it will be called as method on the context object with the code to inject and the options as arguments. All options that are not recognized are passed through to the "missing_block_handler". You are well advised to prefix option names in your extensions. TYPES
BlockCodePart An "ArrayRef" with at least one element that stringifies to either "BEGIN" or "END". The other parts will be stringified and used as the body for the generated block. An example would be this compiletime role composition: ['BEGIN', 'with q{ MyRole }'] CodePart A part of code represented by either a "Str" or a "BlockCodePart". SEE ALSO
o MooseX::Declare o Devel::Declare o Devel::Declare::Context::Simple AUTHOR
Florian Ragwitz <rafl@debian.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2008 by Florian Ragwitz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.18.2 2013-12-14 MooseX::Declare::Context(3pm)
All times are GMT -4. The time now is 08:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy