Hello, my problem is simple & I searched a lot but I couldn't find anything about it:
Basically I'd like to pass $i to a variable, $i being the positional variable; but it is unknown in the beginning so I can't do it like eg. myvar=$3, it HAS to be the "i"..
First, I tried myvar=$($i) (because $i is the number of i (ex 5), and not the positional variable ($5) so we would need in theory another $ to get to the positional variable), doesn't work
I tried this also, though I'm not sure if it's correct:
(in my code, i'd like myvar to get the (2+$a) number for the positional variable).
I already have accomplished this task using sed and arrays, but since I get the variable using awk, I figured I'd ask this question and maybe I can get a cleaner solution using strictly awk.. I just can't quite grasp it in awk.
Story: I'm automating the (re)configuration of network interfaces,... (3 Replies)
Hi,
I have a script that processes the positional parameters provided on the command line, or - if none are provided - uses some defaults instead.
I've currently got it written as follows, which works like a charm, but I was wondering if there is a different/other/better/... way of doing... (2 Replies)
I am using variable to give the location of the file I am using but I get error.
Here is the code:
LogFile=/tmp/log.email
echo -e "could not close the service - error number $error \n" > $LogFile
well this is not all the code but is enough because the problem start when I try to use the... (3 Replies)
I have a following problem:
#!/bin/bash
NUM=`cat accounts | wc -l`;
for i in {1..$NUM}
do
account=`awk "NR==$i" accounts`;
echo -e "\nAccount: $account\n";
sudo ./backup_maildir $account;
done "accounts" is a file with regular e-mail addresses, one in each line.... (2 Replies)
In a Bash script I used getopts command to let a user does something regards to the selected options. The question is: How do you find out what is the name of the file that user inserted in the command line like the following:
The good part is this file is always the last argument in the... (2 Replies)
Hi,
I have to use the vaious kind of filters based on various fields in the input file like - count occurence of cases where "TRK-GRP" = 169 or like "ADDR-DIG" = 80080.
I don;t know the positional variable for all below fields. Please help.
Input File :
+++ BEST 12-05-27 15:06:49 MDI 3478... (2 Replies)
Hi,
I have a script which will be executed using the below command,
bin/nutch crawl urls -dir /data/test/
bin/nutch - Script file
crawl, urls, /data/test/ - Parameters
-dir - Option
The above script should executed from a shell script named test.sh. I have the below code to execute... (2 Replies)
From the command line:
dions-air:scripts dion$ ls -l /Users/dion/Library/Application\ Support/Garmin/Devices/3816821036/History/2014-06-07-055251.TCX
-rw-r--r-- 1 dion staff 157934 7 Jun 06:55 /Users/dion/Library/Application Support/Garmin/Devices/3816821036/History/2014-06-07-055251.TCXworks... (2 Replies)
Hi,
Is there a special positional variables for when using the dot (.)?
Scripts are as below:
$: head -100 x.ksh /tmp/y.ksh
==> x.ksh <==
#!/bin/ksh
#
. /tmp/y.ksh 1234 abcd
echo "yvar1 = $yvar1"
echo "yvar2 = $yvar2"
==> /tmp/y.ksh <==
#!/bin/ksh (2 Replies)
Discussion started by: newbie_01
2 Replies
LEARN ABOUT DEBIAN
html::template::compiled::reference
HTML::Template::Compiled::Reference(3pm) User Contributed Perl Documentation HTML::Template::Compiled::Reference(3pm)NAME
HTML::Template::Compiled::Reference - A quick reference for HTML::Template::Compiled syntax
TAGSTYLES
<TMPL_IF var><TMPL_VAR foo></tmpl_if var>
<!-- TMPL_IF var --><!-- TMPL_VAR foo --><!-- /tmpl_if var -->
<%if var %><%= foo %><%/if var %>
Optional tagstyle 'tt':
[%if var %][%= foo %][%/if var %]
ACCESSING VARIABLES
<%= _.foo %>
outputs foo in the cuurent position of the stash and is the same as
<%= foo %>
<%= .config.url %>
goes to root of parameter stash; like $params->{config}->{url}
<%= ..foo %>
goes one level up in stash
<%= list[3].keyname.method %>
acts like: $stash->[3]->{keyname}->method
TAGS
VAR
<%var foo%> or <%= foo%>
IF, IF_DEFINED, UNLESS, ELSIF, ELSE
conditions like in Perl
LOOP, WHILE, EACH
for-loop and while-loop like in Perl.
<%loop cds%><%= __counter__%>. Title: <%= _.title%><%/loop cds%>
<%loop cds join=", " %><%= _.title%><%/loop cds%>
<%while resultset.next%><%= __counter__%>. <%= _.foo %><%/while %>
<%each hashref%><%= __key__ %>=<%= __value__ %><%/each %> (sorted alphanumeric)
<%each hashref sort=alpha %><%= __key__ %>=<%= __value__ %><%/each %> (sorted alphanumeric)
<%each hashref sort=num %><%= __key__ %>=<%= __value__ %><%/each %> (sorted numeric)
<%each hashref sort=0 %><%= __key__ %>=<%= __value__ %><%/each %> (not sorted)
WITH
<%with cds[0].artist.fanclub%><%= _.address%><%= _.homepage%><%/with %>
INCLUDE, INCLUDE_VAR
<%include template.htc%>
<%include_var param_with_template_name%>
COMMENT, VERBATIM, NOPARSE
<%comment explanation %>
This will not appear in the rendered template.
blah blah...
<%/comment explanation %>
SWITCH, CASE
<%switch .config.language%>
<%case de%>Hallo
<%case es%>Hola
<%case en,default%>Hello
<%/switch .config.language%>
PERL
See section Perl in HTML::Template::Compiled
ATTRIBUTES
Each attribute can be written as
attribute=foo
attribute="some thing"
attribute='some "thing"'
NAME
You can omit the 'name=' here.
<%if var%>var<%elsif name=var2%>var4<%/if%>
Can be used in all tags.
ESCAPE
<%= message escape=html %>
<%= params escape=url %>
<%= params escape=js %>
<%= some_var escape=dump|html%>
Can be used in "VAR"-tags.
DEFAULT
<%= this.var.might_be_undef default="my fault" %>
Can be used in "VAR"-tags.
ALIAS
<%loop cds alias="cd" %><%= cd.title %><%/loop cds %>
Can be used in "LOOP" and "WHILE". Works like "SET_VAR" and is short for
<%loop cds %><%set_var cd value=_ %><%= cd.title %><%/loop cds %>
Useful for nested loops.
SET_VAR
<%set_var myvar value=.another.var %>
<%set_var myvar2 expr="60 * 60 * 24" %>
This creates a variable similar to local() in perl. To use such a var or an alias in includes, you must use "USE_VARS" in the include.
USE_VARS
<!-- recognize myvar and myvar2 as variables not parameter stash -->
<%use_vars myvar,myvar2 %>
myvar: <%= myvar %>
JOIN
<%loop cds join=", " %><%= _.title%><%/loop cds%>
can be used in "LOOP"
BREAK
<%loop cds break="3" %>
<%= _.title%><%if __break__ %>
</%if %>
<%/loop cds%>
Sets "__break__" to 1 every xth loop. Can be used in "LOOP", "WHILE" and "EACH"
OPTIONS
(loop)_context_vars
<%= __index__ %> the current loop index starting at 0
<%= __counter__ %> the current loop index starting at 1
<%= __first__ %> true if first iteration
<%= __last__ %> true if last iteration
<%= __odd__ %> true if __counter__ is odd
<%= __inner__ %> true if not last or first iteration
<%= __key__ %> the key of an EACH iteration
<%= __value__ %> the value of an EACH iteration
<%= __break__ %> see L<"BREAK"> above
<%= __filename__ %> filename of current template (since 0.91_001)
<%= __filenameshort__ %> short filename of current template (since 0.91_001)
perl v5.14.2 2012-05-26 HTML::Template::Compiled::Reference(3pm)