I have the following simplified code that I am planning on putting into a larger shell script. I have been butchering it to try and make work amongst google searches and reading awk documentation.
I want to evaluate the output from the syntax below and compare it with the value "[off]" and print the word "MUTED" if it matches.
The command essentially outputs either [on] or [off]
I have been unable to find an example and I'm not even sure it could be done - Would an awk guru please provide some insight.
The input to awk from the amixer command looks like this for anyone that does not have amixer available and would like to test using a text file (the [off] becomes [on] and visa versa each time the command is executed).
Hi
How can i compare a string using if statement in a script?
For eg:
I have
filename="abc.sh"
if ;then
{
.......
.......
}
fi
but this doesnot work .. How will i execute this ??
Thanks in advance (1 Reply)
Hello,
I have this:
#!/usr/bin/ksh
V1=ABC
str="hello 123;${V1}"
eval "echo $str"
i get
hello 123
/script.sh ABC not found
However eval works if $str variable doesn't contain a semicolumn (eg if str="hello 123~${v1}"
running the eval statement above would produce (2 Replies)
Hi,
I have a program written in awk and I want to extend it to do another task.
My program is a list of CVS log reports of a repository. For each file, I have some fields. One of the fields is the comment field. I want to know how I can check if a comment (which is a free text field)... (8 Replies)
Hi,
I am trying to do evaluate one numerical string after substitution.
++++++++++++++++==
What I have = "7.04+2.3Xlog(0.72e-6X1.0e6)X1.9596"
What I need = evaluate 7.04+2.3*log(0.72e-6*1.0e6)*1.9596 = 5.55941
what I am doing;
echo "7.04+2.3Xlog(0.72e-6X1.0e6)X1.9596" | awk... (2 Replies)
I am trying to test two conditions in a single if and getting syntax error on -a and &&
if ] ; then
echo "variable a equals to variable b"
else
echo "variable a not equal to variable b"
fi
in second attempt I used -a instead of &&, referring to other website, but not sure that... (1 Reply)
Need help for awk..
file will have comma separated numbers, I need check digits before 10 numbers eg ( 001)1234567890
Basically want to check country code of a mobile number.
eg:
abc,def,data, data,0011234567890, data,data
Script should be checking country code with 001, I will pass... (10 Replies)
Hi all,
I was doing some string manipulation in my script and wanted to try using awk. However, I have been stuck with string compare. A simplified form of my conundrum is given below:
The below prints expected result (prints "Completed because that is the second element"):
$ echo... (5 Replies)
I want to create a conditional expression string and pass in an awk script. My script is as below...
comm="\$3 == "hello""
awk -F "^T" -v command="${comm}" ' {
if ( command ) { print "hye" }
}' testBut the statement "if ( command )" always evaluates to true which is not... (5 Replies)
I have to display only those subscribers which are in "unconnected state" and the date is 90 days older than today's date.
Below command is used for this purpose:
cat vfsubscriber_20170817.csv | sed -e 's/^"//' -e '1d' | \
nawk -F '",' '{if ( (substr($11,2,4) == 2017) && ( substr($11,2,8)... (1 Reply)
I have below code inside my awk script
if ( $0 ~ /SVC IN:/ )
{
svc_in=substr( $0,23 , 3);
if (msg_start == 1 && msg_end == 0)
{
msg_arr=$0;
}
}
else if ( $0 ~ /^SVC OUT:/ )
{
svc_out=substr( $0, 9, 3);
if (msg_start == 1 && msg_end == 0)
... (6 Replies)
Discussion started by: bhagya123
6 Replies
LEARN ABOUT LINUX
igawk
IGAWK(1) Utility Commands IGAWK(1)NAME
igawk - gawk with include files
SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ...
igawk [ all gawk options ] [ -- ] program-text file ...
DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1).
AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like
@include getopt.awk
in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path.
OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports.
EXAMPLES
cat << EOF > test.awk
@include getopt.awk
BEGIN {
while (getopt(ARGC, ARGV, "am:q") != -1)
...
}
EOF
igawk -f test.awk
SEE ALSO gawk(1)
Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995.
AUTHOR
Arnold Robbins (arnold@skeeve.com).
Free Software Foundation Nov 3 1999 IGAWK(1)