Sponsored Content
Top Forums Shell Programming and Scripting Perl to update field based on a specific set of rules Post 303001076 by cmccabe on Wednesday 26th of July 2017 07:30:33 AM
Old 07-26-2017
Thank you very much Smilie.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Update a field in a file based on condition

Hi i am new to scripting. i have a file file.dat with content as : CONTENT_STORAGE PERCENTAGE FLAG: /storage_01 64% 0 /storage_02 17% 1 I need to update the value of FLAG for a particular CONTENT_STORAGE value I have written the following code #!/bin/sh threshold=20... (1 Reply)
Discussion started by: kichu
1 Replies

2. Shell Programming and Scripting

Help with allocated text content based on specific rules...

Input file format: /tag="ABL" /note="abl homolog 2 /tag="ABLIM1" /note="actin binding LIM 1 /tag="ABP1" /note="amiloride binding protein 1 (amine oxidase (copper- containing)) /tag="ABR" /note="active BCR-related /tag="AC003042.1" /note="SDR family member 11 precursor . . . (4 Replies)
Discussion started by: perl_beginner
4 Replies

3. Shell Programming and Scripting

Update specific field in a line of text file

I have a text file like this: subject1:LecturerA:10 subject2:LecturerA:40 if I was given string in column 1 and 2 (which are subject 1 and LecturerA) , i need to update 3rd field of that line containing that given string , which is, number 10 need to be updated to 100 ,for example. The... (6 Replies)
Discussion started by: bmtoan
6 Replies

4. Shell Programming and Scripting

Add specific string to last field of each line in perl based on value

I am trying to add a condition to the below perl that will capture the GTtag and place a specific string in the last field of each line. The problem is that the GT value used is not right after the tag rather it is a few fields away. The values should always be 0/1 or 1/2 and are in bold in the... (12 Replies)
Discussion started by: cmccabe
12 Replies

5. Shell Programming and Scripting

awk to update value in field based on another field

In the tab-delimeted input file below I am trying to use awk to update the value in $2 if TYPE=ins in bold, by adding the value of HRUN= in italics. In the below since in line 1 TYPE=ins the 117282541 value in $2 has 6 added because that is the value of HRUN=. Hopefully the awk is a start but I... (2 Replies)
Discussion started by: cmccabe
2 Replies

6. Shell Programming and Scripting

Perl to update field in file based of match to another file

In the perl below I am trying to set/update the value of $14 (last field) in file2, using the matching NM_ in $12 or $9 in file2 with the NM_ in $2 of file1. The lengths of $9 and $12 can be variable but what is consistent is the start pattern will always be NM_ and the end pattern is always ;... (4 Replies)
Discussion started by: cmccabe
4 Replies

7. Shell Programming and Scripting

Perl to change value based on set of rules

In the perl there is a default rule that sets f to VUS, and then a seris of rules that will change f based on the result that is obtained from the rule. The code below is a rule that is supposed to be applicable to lines 2-4 because this rule just looks at the digit in f. So in line 2 f is 27... (4 Replies)
Discussion started by: cmccabe
4 Replies

8. Shell Programming and Scripting

awk to assign points to variables based on conditions and update specific field

I have been reading old posts and trying to come up with a solution for the below: Use a tab-delimited input file to assign point to variables that are used to update a specific field, Rank. I really couldn't find too much in the way of assigning points to variable, but made an attempt at an awk... (4 Replies)
Discussion started by: cmccabe
4 Replies

9. Shell Programming and Scripting

Update a specific field in file with Variable value based on other Key Word

I have an input file with A=xyz B=pqr I would want the value in Second Field (xyz or pqr) updated with a value present in Shell Variable based on the value passed in the first field. (A or B ) while read line do NEW_VALUE = `some functionality done on $line` If $line=First Field-... (1 Reply)
Discussion started by: infernalhell
1 Replies

10. UNIX for Beginners Questions & Answers

Problem with getting awk to multiply a field by a value set based on condition of another field

Hi, So awk is driving me crazy on this one. I have searched everywhere and read man, docs and every related post Google can find and still no luck. The actual files I need to run this on are sensitive in nature, but it is the same thing as if I needed to calculate weighted grades for multiple... (15 Replies)
Discussion started by: cotilloe
15 Replies
File::Find::Rule::Perl(3)				User Contributed Perl Documentation				 File::Find::Rule::Perl(3)

NAME
File::Find::Rule::Perl - Common rules for searching for Perl things SYNOPSIS
use File::Find::Rule (); use File::Find::Rule::Perl (); # Find all Perl files smaller than 10k my @files = File::Find::Rule->perl_file ->size('<10Ki') ->in('dir'); # Locate all the modules that PAUSE will index my @mod = File::Find::Rule->no_index ->perl_module ->in('My-Distribution'); DESCRIPTION
I write a lot of things that muck with Perl files. And it always annoyed me that finding "perl files" requires a moderately complex File::Find::Rule pattern. File::Find::Rule::Perl provides methods for finding various types Perl-related files, or replicating search queries run on a distribution in various parts of the CPAN ecosystem. METHODS
perl_module The "perl_module" rule locates perl modules. That is, files that are named "*.pm". This rule is equivalent to "->"file->name( '*.pm' )> and is included primarily for completeness. perl_test The "perl_test" rule locates perl test scripts. That is, files that are named "*.t". This rule is equivalent to "->"file->name( '*.t' )> and is included primarily for completeness. perl_installer The "perl_installer" rule locates perl distribution installers. That is, it locates "Makefile.PL" and "Build.PL" files. perl_script The "perl_script" rule locates perl scripts. This is any file that ends in .pl, or any files without extensions that have a perl "hash-bang" line. perl_file The "perl_file" rule locates all files containing Perl code. This includes all the files matching the above "perl_module", "perl_test", "perl_installer" and "perl_script" rules. no_index # Provide the rules directly $rule->no_index( directory => [ 'inc', 't', 'examples' ], file => [ 'Foo.pm', 'lib/Foo.pm' ], ); # Provide a META.yml to use $rule->no_index( 'META.yml' ); # Provide a dist root directory to look for a META.yml in $rule->no_index( 'My-Distribution' ); # Automatically pick up a META.yml from the target directory $rule->no_index->in( 'My-Distribution' ); The "no_index" method applies a set of rules as per the no_index section in a "META.yml" file. SUPPORT
Bugs should always be submitted via the CPAN bug tracker <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Find-Rule-Perl> For other issues, contact the maintainer AUTHOR
Adam Kennedy <adamk@cpan.org> SEE ALSO
<http://ali.as/>, File::Find::Rule, File::Find::Rule::PPI COPYRIGHT
Copyright 2006 - 2012 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.16.3 2012-10-31 File::Find::Rule::Perl(3)
All times are GMT -4. The time now is 04:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy