10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Environment:
BASH version: GNU bash, version 3.2.51(1)-release (sparc-sun-solaris2.10)
Copyright (C) 2007 Free Software Foundation, Inc.
OS: Oracle Solaris 10 9/10 s10s_u9wos_14a SPARC
Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
... (4 Replies)
Discussion started by: os2mac
4 Replies
2. Shell Programming and Scripting
#!/bin/bash
#timetest
TIMENOW="$(date)"
T1=12:00:00
echo $TIMENOW >timenow
cat timenow |cut -f4 -d' ' >time1
T2=$(sed -n "${1}p" time1)
echo "T1 = " $T1
echo "T2 = " $T2
if then
echo $T1
else
echo $T2
fi
I thought scripting was simple! So why does this script result in:
T1 =... (4 Replies)
Discussion started by: habuchas
4 Replies
3. UNIX for Dummies Questions & Answers
Hi,
i can print 2nd, 4th and 6th columns in a file using the shell command:
awk -F "|" '{print $2 $4 $6}' file1.txt
Now, the position and number of columns can be variable and from a variable POSLIST
So let's say
POSLIST='$2 $4 $6'
when i use the command:
a)
awk -F "|" '{print... (2 Replies)
Discussion started by: ysrini
2 Replies
4. UNIX for Dummies Questions & Answers
HI,
I have 5 variables var1, var2, var3, var4 and var5
I need to initialize all of them to zero.
Is there a way to do it in a single line
something like this
var1=var2=var3=var4=var5=0.
I am unable to achieve this.
What is going wrong? (2 Replies)
Discussion started by: paku
2 Replies
5. Shell Programming and Scripting
kindly find below:-
var="'(]\\{}\$\""
echo $var # it wil give this '(]\{}$"
echo "$var" # '(]\{}$" Doesn't make a difference why???.
if we set IFS to '\' also the below happens
IFS='\'
echo $var # '(] {}$" \ converted to space. Why? weird!!
echo "$var"... (3 Replies)
Discussion started by: ahmad.diab
3 Replies
6. Shell Programming and Scripting
is it possible to call a variable in a case statement, for example
lsmonth=Jan|Feb
l |while read ans
do
mymonth=`echo $ans |awk '{print $6}'`
case $mymonth in
$lsmonth) echo do something
;;
*) echo do something else
;;
esac
done
I want to use $lsmonth... (8 Replies)
Discussion started by: gefa
8 Replies
7. Shell Programming and Scripting
meas is a shell variable, and this works perfectly fine for me:
awk -v var=$meas -F, '$1==var' /abcd/efgh.txt > temp1.csv
However, i want to introduce another shell variable, named, defnfile in the statement, in place of hardcoded path for efgh.txt like:
awk -v var=$meas -F, '$1==var'... (3 Replies)
Discussion started by: indianjassi
3 Replies
8. Shell Programming and Scripting
Ok, So up front I'm going to say that I'm a very elementary scripter, and I tend to use tools I don't fully understand, but I shotgun at something until I can get it to work...that said, I can't for the life of me understand why I can't get this to go down the way I want it to.
The goal:
-to... (6 Replies)
Discussion started by: DeCoTwc
6 Replies
9. Shell Programming and Scripting
I am just wondering if it's possible to refer to variables within a sed statement as follows:-
cat $file | sed -e 1's/$oldtext/$newtext/' > $file
as when I run the script, the variables are not recognised and nothing happens..??
Thanks (5 Replies)
Discussion started by: sirtrancealot
5 Replies
10. UNIX for Dummies Questions & Answers
With the if statement:
if
How can I make it so it accepts a wildcard after the ${CURR_DAY_MONTH} variable?
Putting
a -f /webtrends/SUN/mrw2/access.${CURR_DAY_DAY}${CURR_DAY_MONTH}*
won't work, right? I think I need some kind of special character so it knows the wildcard is... (3 Replies)
Discussion started by: LordJezo
3 Replies