10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All
I am trying to fetch the size of three files into three separate variables within a for loop and am doing something like this:
for i in ATT1 ATT2 ATT3
do
size_$i=`ls -ltr $i | awk '{print $5}'`
echo ${size_$i}
done
but am getting the below error:
ksh: size_ATT1=522: not... (3 Replies)
Discussion started by: swasid
3 Replies
2. Shell Programming and Scripting
Here's my code:
awk -F '' 'NR==FNR {
if (/time/ && $5>10)
A=$2" "$3":"$4":"($5-01)
else if (/time/ && $5<01)
A=$2" "$3":"$4-01":"(59-$5)
else if (/time/ && $5<=10)
A=$2" "$3":"$4":0"($5-01)
else if (/close/) {
B=0
n1=n2;
... (2 Replies)
Discussion started by: klane
2 Replies
3. Shell Programming and Scripting
Hi Everyone,
I am currently tasked with some reporting on various Unix based OSes. I have a script deployed that runs and grabs the information I am looking for, and has a bit of logic to output the desired result into a text file.
Example of my text file:
multiUsers=yes... (1 Reply)
Discussion started by: Zaphod_B
1 Replies
4. Shell Programming and Scripting
Hello All,
Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....?
I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping
through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies
5. UNIX for Dummies Questions & Answers
Hi All,
Thanks all of you for the help you provide to me. Well, I have one more problem, where I am trying to pull file system information in the loop and display the filesystem percentege. I am using following code to achive this, nut it's giving the weired output.
My file system is
... (1 Reply)
Discussion started by: alok.behria
1 Replies
6. Shell Programming and Scripting
I obviously haven't learned my lesson with shell and whitespace.
find /path/to/some/where/ -name "*.pdf" | awk '{print $5}'| uniq -d
results:
some Corporation
other Corporate junk
firmx
Works fine from cmdline but the whitespace turns into another FS in a for loop.
for... (7 Replies)
Discussion started by: s_becker
7 Replies
7. Shell Programming and Scripting
Hi there, I am checking disk spaced used on a box
# df -k | grep dsk | awk {'print $3'}
2055463
20165785
18310202
32274406
I want to somehow add them up but am no quite sure how to do this in a loop. ...i.e
for n in 'df -k | grep dsk | awk {'print $3}'
do
<some adding... (1 Reply)
Discussion started by: hcclnoodles
1 Replies
8. Shell Programming and Scripting
- I m retreving values from database and wish to use those values later in my shell script. I m placing these values in an array da_data but outside loop array is empty.Problem is its treating array as local inside loop hence array is empty outside loop.
Plz go through the script and suggest how... (1 Reply)
Discussion started by: Devesh5683
1 Replies
9. Shell Programming and Scripting
I have a set of variables:
f1="./someFolder"
.
.
f10="./someOtherFolder"
And I'm trying to use the following loop
for (( i = 0; i <= 10; i++ ))
do
temp=f$i
done
I'm trying the get the values from my set of variable to make directories, but I can't seem the get those value... (3 Replies)
Discussion started by: kriuz
3 Replies
10. Shell Programming and Scripting
Hi all,
I've been trying to get this to work for ages to no avail. I've searched this site and googled but cannot find a satisfactory answer.
I've got a while loop, like this
while read line
do
echo "$line"
done < file_name
Now, my problem is that most of the lines in the file... (3 Replies)
Discussion started by: zazzybob
3 Replies
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)