09-22-2017
Did you test your script so far ? have you performed some "unity testing" to validate one by one that your conditions work as you expect ?
In condition 1 , where does this (see in if(index$f["FuncrefGene"]... ) "index$f" come from ?
Why using the dollar sign in variable settings ? when assigning the value 3 to the variable "var2" in awk, shouldn't you use var2=3 rather than $var2=3 ??? same in testing : you are in awk, not in shell so use : if ( var2 == 3 ) { ... } rather than if ( $var2 == 3 ) { ... }
Last edited by ctsgnb; 09-22-2017 at 09:41 AM..
This User Gave Thanks to ctsgnb For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello Friends,
I have a file(InputFile.csv) with the following columns(the columns are pipe-delimited):
ColA|ColB|ColC|ColD|ColE|ColF
Now for this file, I have to get those records which fulfil the following condition:
If "ColB" is NOT NULL and "ColD" has values one of the following... (9 Replies)
Discussion started by: mehimadri
9 Replies
2. Shell Programming and Scripting
With this script i want to print the output to a specific field-number . Can anybody help?
awk 'NR=FNR{split(FILENAME,fn,"_");nr=$2;f = $1} END{for (i=1;i<=f;i++) print i,$fn=nr}' input_5.csv input_6.csvinput_5.csv
4 135
5 185
6 85
11 30input_6.csv
1 90
3 58
4 135
7 60
8 55
10... (1 Reply)
Discussion started by: sdf
1 Replies
3. Shell Programming and Scripting
Hello,
I'm trying the solve the following problem.
I have a file which I intend to use as a csv called master.csv
The columns are separated by commas.
I want to change the text on a specific row in either column 3,4,5 or 6 from xxx to yyy depending upon if column 1 matches a specified pattern.... (3 Replies)
Discussion started by: cyphex
3 Replies
4. Shell Programming and Scripting
Please help me to write a script
Match with ACNO & NAME if it matched calculate the total val1 val2 val3 and val4 and GT is total of ACNO wise.please check the output
Table
-----------------
1005|ANDP|ACN|20|50|10|30
1005|ANDP|ACN|20|10|30|40
1001|AND|NAC|40|50|40|50... (22 Replies)
Discussion started by: kalia4u
22 Replies
5. Shell Programming and Scripting
If $1 in file1 matches $2 in file2. Then the value in $2 of file2 is updated to $1"."$2 of file2. The awk seems to only match the two files but not update. Thank you :).
awk
awk 'NR==FNR{A ; next} $1 in A { $2 = a }1' file1 file2
file1
name version
NM_000593 5
NM_001257406... (3 Replies)
Discussion started by: cmccabe
3 Replies
6. Shell Programming and Scripting
I am trying to use awk to match two files that are tab-delimited. When a match is found between file1 $1 and file2 $4, $4 in file2 is updated using the $2 value in file1. If no match is found then the next line is processed. Thank you :).
file1
uc001bwr.3 ADC
uc001bws.3 ADC... (4 Replies)
Discussion started by: cmccabe
4 Replies
7. Shell Programming and Scripting
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
8. Shell Programming and Scripting
I am trying to use awk to update the below tab-delimited file based on 5 different rules/conditions. The final output is also
tab-delimited and each line in the file will meet one of the conditions. My attemp is below as well though I am not very confident in it. Thank you :).
Condition 1: The... (10 Replies)
Discussion started by: cmccabe
10 Replies
9. Shell Programming and Scripting
In the perl below, which does execute, I am having trouble with the else in Rule 3. The digit in f{8} is extracted and used to update f accordinly along with the value in f.
There can be either - * or + before the number that is extracted but the same logic applies, that is if the value is greater... (5 Replies)
Discussion started by: cmccabe
5 Replies
10. Shell Programming and Scripting
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
LEARN ABOUT SUSE
template::stash
Template::Stash(3) User Contributed Perl Documentation Template::Stash(3)
NAME
Template::Stash - Magical storage for template variables
SYNOPSIS
use Template::Stash;
my $stash = Template::Stash->new(\%vars);
# get variable values
$value = $stash->get($variable);
$value = $stash->get(@compound);
# set variable value
$stash->set($variable, $value);
$stash->set(@compound, $value);
# default variable value
$stash->set($variable, $value, 1);
$stash->set(@compound, $value, 1);
# set variable values en masse
$stash->update(\%new_vars)
# methods for (de-)localising variables
$stash = $stash->clone(\%new_vars);
$stash = $stash->declone();
DESCRIPTION
The "Template::Stash" module defines an object class which is used to store variable values for the runtime use of the template processor.
Variable values are stored internally in a hash reference (which itself is blessed to create the object) and are accessible via the get()
and set() methods.
Variables may reference hash arrays, lists, subroutines and objects as well as simple values. The stash automatically performs the right
magic when dealing with variables, calling code or object methods, indexing into lists, hashes, etc.
The stash has clone() and declone() methods which are used by the template processor to make temporary copies of the stash for localising
changes made to variables.
PUBLIC METHODS
new(\%params)
The "new()" constructor method creates and returns a reference to a new "Template::Stash" object.
my $stash = Template::Stash->new();
A hash reference may be passed to provide variables and values which should be used to initialise the stash.
my $stash = Template::Stash->new({ var1 => 'value1',
var2 => 'value2' });
get($variable)
The "get()" method retrieves the variable named by the first parameter.
$value = $stash->get('var1');
Dotted compound variables can be retrieved by specifying the variable elements by reference to a list. Each node in the variable occupies
two entries in the list. The first gives the name of the variable element, the second is a reference to a list of arguments for that
element, or 0 if none.
[% foo.bar(10).baz(20) %]
$stash->get([ 'foo', 0, 'bar', [ 10 ], 'baz', [ 20 ] ]);
set($variable, $value, $default)
The "set()" method sets the variable name in the first parameter to the value specified in the second.
$stash->set('var1', 'value1');
If the third parameter evaluates to a true value, the variable is set only if it did not have a true value before.
$stash->set('var2', 'default_value', 1);
Dotted compound variables may be specified as per get() above.
[% foo.bar = 30 %]
$stash->set([ 'foo', 0, 'bar', 0 ], 30);
The magical variable '"IMPORT"' can be specified whose corresponding value should be a hash reference. The contents of the hash array are
copied (i.e. imported) into the current namespace.
# foo.bar = baz, foo.wiz = waz
$stash->set('foo', { 'bar' => 'baz', 'wiz' => 'waz' });
# import 'foo' into main namespace: bar = baz, wiz = waz
$stash->set('IMPORT', $stash->get('foo'));
clone(\%params)
The "clone()" method creates and returns a new "Template::Stash" object which represents a localised copy of the parent stash. Variables
can be freely updated in the cloned stash and when declone() is called, the original stash is returned with all its members intact and in
the same state as they were before "clone()" was called.
For convenience, a hash of parameters may be passed into "clone()" which is used to update any simple variable (i.e. those that don't
contain any namespace elements like "foo" and "bar" but not "foo.bar") variables while cloning the stash. For adding and updating complex
variables, the set() method should be used after calling "clone()." This will correctly resolve and/or create any necessary namespace
hashes.
A cloned stash maintains a reference to the stash that it was copied from in its "_PARENT" member.
declone()
The "declone()" method returns the "_PARENT" reference and can be used to restore the state of a stash as described above.
AUTHOR
Andy Wardley <abw@wardley.org> <http://wardley.org/>
COPYRIGHT
Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Template, Template::Context
perl v5.12.1 2009-05-20 Template::Stash(3)