10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
input:
AAA|1
my script (the function is just an example):
gawk 'BEGIN{FS=OFS="|"}
function repeat(str, n, rep, i){
for(i=1; i<=n; i++)
rep=rep str
return rep
}
{
variable_1=repeat($1,$2)
variable_2=repeat($1,$2+1)
variable_3=repeat($1,$2+3)
... (5 Replies)
Discussion started by: beca123456
5 Replies
2. UNIX for Dummies Questions & Answers
HI
i was studying about variable substitution. below are info which was given in a online tutorial.
${parameter:-word}---> If parameter is null or unset, word is substituted for parameter.
The value of parameter does not change.
${parameter:=word}---> If parameter is null or... (3 Replies)
Discussion started by: scriptor
3 Replies
3. Shell Programming and Scripting
Hi All,
I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command.
The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Discussion started by: G.K.K
7 Replies
4. Shell Programming and Scripting
HI,
This is the code I am using:
awk -v aaa="connect" 'BEGIN {IGNORECASE} /aaa/,/!/ {print NR}' bb
This does not throw any error but it does not work. Pls help
Thanks. (4 Replies)
Discussion started by: sudvishw
4 Replies
5. Shell Programming and Scripting
Hi
How are you people ..
I am facing another problem regarding awk below is my code
-bash-3.00$ export a=10
-bash-3.00$ echo $a
10
-bash-3.00$ echo "" | nawk -v var=$a ' { if(var=10) { print "abc" } else { print "def"} } '
abc
-bash-3.00$ echo "" | nawk -v var=$a ' { if(var==10)... (2 Replies)
Discussion started by: aishsimplesweet
2 Replies
6. Shell Programming and Scripting
For example I have variable like below
echo $OUTPUT
/some/path/`uname -n`
when I try to use the variable OUTPUT like below
cd $OUTPUT or cd ${OUTPUT}
I am getting bad substituion error message
$ cd $OUTPUT
ksh: cd: bad substitution
$ cd ${OUTPUT}
ksh: cd: bad substitution
... (1 Reply)
Discussion started by: rajukv
1 Replies
7. Shell Programming and Scripting
Hi,
I have a variable to be substituted in awk. I am using AIX 5.3. Here is my piece of code:
REPL_DT=`date +'%Y\\\\\\\\\/%m\\\\\\\\\/%d'`
NEW_LINE=$(echo $Line | awk '{sub ($4, '$REPL_DT'); printf "# %-7s %9s %18s\n", $2,$3,$4}')
sed $n" s/.*/$NEW_LINE/" kfile > tmp
mv tmp kfile
Here,... (2 Replies)
Discussion started by: sugan
2 Replies
8. Shell Programming and Scripting
Hi,
I am facing a strange problem. I have a script that used the following to search and replace text:
sed 's/'"${find_var_parm}"'/'"${find_var_filter}"'/g' $ParmFile > $TempFile
The values of $find_var_parm and $find_var_filter are set based on search criteria. The above seems to be working... (2 Replies)
Discussion started by: arsh
2 Replies
9. Shell Programming and Scripting
Hello,
i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem.
my var1 is a string constructed like this:
filename1 filerev1 filepath1
my var2 is another string constructed like this:
filename2 filerev2 filepath2
when i do... (2 Replies)
Discussion started by: alrinno
2 Replies
10. UNIX for Dummies Questions & Answers
for the command below, it looks for the 3rd field value matching "P" and printing it.
awk '{if ($3 == "P") print}' file
how would i express this if i use a loop to find more that 1 variable fro a list? this doesn't seem to work...
cat list | while read n
do
awk '{if ($3 == "$n") print}'... (1 Reply)
Discussion started by: apalex
1 Replies