How can I pass the name of the variable inside a for statment
I have a script something like below:
classA=12
classB=14
classC=16
# classD = 20
all_class="classA classB classC"
for i in $all_class
do
echo $i = $($i) #<---- this one not work
#echo $i = $(echo $i) ... (1 Reply)
hi,
i have store variable in $var i want to print it in $3 of file using awk.
how can i do it?
file :
var1,var2,var3
var5,var6,var7
var8,var9,var10
.
.
.
i want to print $var in $3 ( for example var3 or var7 or var10)
thanks (3 Replies)
Hello,
i need to redirect the output of print to a variable file name:
#This is normal
awk '{ print $17 > "output.txt" }' input
#I need something like this
awk '{ print $17 > "output_${25}.txt" }' input
how to format the output file name to contain a variable? (6 Replies)
Let's say I want to print the arguments $4 till $#, how can I do this?
$# contains the number of arguments
$@ contain all the arguments as string
What i need is something like
for i in $4_till_$#; do
#do something with $i
convert $i ~/$output
done
The first 3 arguments are used as options... (6 Replies)
I have list of files:
ls
a.pdf
b.pdf
c.pdf
and so on...
and I have a file like this:
cat file1
apple
mango
pear
and so on...
I want to rename my file like this: (7 Replies)
hey,
just want to ask how to do this.
ex.
g="hi i am john"
h=`echo $g | awk '{print $2}'`
echo $h
OUTPUT is 'i'
What if I want to use a variable instead of using '2', how do I do that?
Because this one does not work:
a=2
h=`echo $g | awk '{print ${$a}}'`
this one also does not... (3 Replies)
i have this variable:
varT="1--2--3--5"
i want to use awk to print field 3 from this variable. i dont want to do the "echo $varT".
but here's my awk code:
awk -v valA="$varT" "BEGIN {print valA}"
this prints the entire line. i feel like i'm so close to getting what i want. i... (4 Replies)
Hi guys,
I have a file "abc.dat" in below format:
FILE_PATH||||$F_PATH
TABLE_LIST||||a|b|c
SYST_NM||||${SRC_SYST}
Now I am trying to read the above file and want to print the value for above dollar variables F_PATH and SRC_SYST. The problem is it's reading the dollar variables as... (5 Replies)
The bash bash below extracts the oldest folder from a directory and stores it in filename
That result will match a line in bold in input. In the matching line there is an_xxx digit in italics that
(once the leading zero is removed) will match a line in link. That is the lint to print in output.... (2 Replies)
The file f1 contains the text "body" (shell prompt is "$"):
$ cat ~/path/f1
body
How to print contents of f1 when the f1 path is in a variable?
Here is my failed attempt:
$ f1="~/path/f1"
$ echo $f1
~/path/f1
$ cat $f1
cat: '~/path/f1': No such file or directory (2 Replies)