That will print each line containing the literal string RANGE anywhere on the line. But, you're on the right path. Try:
or, using default actions, just:
Last edited by Don Cragun; 08-10-2015 at 10:54 PM..
Reason: Add -F option to the awk statement.
This User Gave Thanks to Don Cragun For This Post:
(i tend to use/(believe that) variables (are) just like regular strings)
BTW Don, i belive you're missing a -F,.
Just why again does a variable not expand (as in: represents the assigned value) when passed with the first method?
Because, just tonight i've had an issue resolving the properly limited output of such an $2 ~ VARNAME condition, as it printed 2 lines, allthough just one was expected, but the other was similar.
Namely, i did VARNAME=bindir and file contained bindir= and sbindir=, and the values of both were output at each of them, which in regard of the initial purpose has to be considered a malfunction (imo).
Me solved it (there) with ${!VARNAME}, but thats not an option here
(i tend to use/(believe that) variables (are) just like regular strings)
BTW Don, i belive you're missing a -F,.
Just why again does a variable not expand (as in: represents the assigned value) when passed with the first method?
Because, just tonight i've had an issue resolving the properly limited output of such an $2 ~ VARNAME condition, as it printed 2 lines, allthough just one was expected, but the other was similar.
Namely, i did VARNAME=bindir and file contained bindir= and sbindir=, and the values of both were output at each of them, which in regard of the initial purpose has to be considered a malfunction (imo).
Me solved it (there) with ${!VARNAME}, but thats not an option here
Hi sea,
Yes, I missed specifying the field separator. I will fix that in my earlier post shortly. Thank you for pointing it out to me.
Matching in awk uses extended regular expressions (EREs). An ERE in awk is specified by a string or by an ERE token when it is used as the 2nd operand of a ~ or !~ operator; when setting FS inside an awk script; when used as the ERE argument in a gsub(), match(), or sub() function call; and when it is used as the field separator argument in a split() function call. An ERE token is an ERE surrounded by / characters. A string can be a literal string surrounded by " characters, the expansion of a variable, or a concatenation of variable expansions and quoted strings. An ERE token (but not a string) can also be used as the pattern in a pattern/action pair in an awk statement (and in that case /ERE/ is identical in meaning to $0~/ERE/). (A string in this context evaluates to true if the string is not an empty string. A matching operation is not performed in this case.)
A variable in awk does not expand when it is inside quotes and does not expand when it is inside an ERE token just like a variable doesn't expand in the shell when it is included in a string surrounded by single quotes. This is true if the variable is set using a -v variable=value option to awk, is set inside the awk script, or is set as a variable=value operand mixed in with the list of filenames at the end of an awk command invocation.
As with any other RE match, if you want a match to occur at the start or end of a field, you need to use an RE anchor operator (such as in $2 ~ ("^" VARNAME) to find bindir= only if it appears at the start of field 2).
This User Gave Thanks to Don Cragun For This Post:
I have a file.txt containing the following:
Query= HWI-ST863:386:C5Y8UACXX:3:2302:16454:89688 1:N:0:ACACGAAT
Length=100
Score E
Sequences producing significant alignments: (Bits) Value
... (2 Replies)
In the below I can not seem to add a line that will add Not low if the statement in bold is not true or meet. I guess when the first if statement is true/meet then print low, otherwise print Not low in $(NF + 1). I am not sure how to correctly add this. Thank you :).
if(low <= $2 && $2 <=... (5 Replies)
Hi All,
Seeking for your assistance on how to append the specific string when $3 condion met.
ex. file1.txt
ar0050046b16,5,888,0,0,0,0.00,0.00,0.00,0.00,25689.55
ar0050046b16,5,0,0,0,0,0.00,0.00,0.00,0.00,25689.55
ar0050046b16,5,0,0,0,0,0.00,0.00,0.00,0.00,25689.55
expected output:... (5 Replies)
Hi All,
Seeking for your assistance to print all the specific field when the condition met.
Ex:
file1.txt
1|203|3|31243|5341|6452|623|22|00|01
3|45345|123214|6534|3423|6565|643|343|232|10
if field 1 = 1 and field 3 = 3 and field 5 = 5341 and field 6 = 6452
it will print from $1 to $10.... (2 Replies)
i have a table like this:
id, senderNumber, blacklist
-----------------------------
1 0835636326 Y
2 0373562343 Y
3 0273646833 Y
and I want to delete automatically if a new inserted row on another table consist anything on senderNumber column above using a BASH Script
I... (9 Replies)
only wc -l greater than 0 then send email to owner, otherwise do nothing.
ie.
result=powermt display dev=all|awk '{print $7}'|grep -i dead|wc -l
if
then
echo $result
else
:
fi
mailx -s "there is dead path (s)" "mymail@mydomain.com"
-----------
it is not working... (2 Replies)
All,
I wrote the following section of code (which logically in PHP would of worked):
tmpPATH=${1}
tmpTAG=${2}
if
then
while read tmpTAG tmpPATH
do
fi
echo $tmpTAG
echo $tmpPATH
if
then
done < ./config.cfg
fi (4 Replies)
Hello all, I created the below script....and it seemed to be working fine. My problem is i want the script to ignore rest of the things if my condition is not met but do not exit....
#!/bin/ksh
###########################
###########################
# Set name of the listener, this... (2 Replies)
I am having trouble figuring this code
I want to grep a text from a file and if it match certain text it break out of the loop or it should continue searching for the text
Here is what I have written but it isn't working
while true
f=`grep 'END OF STATUS REPORT' filename`
do
if ... (9 Replies)
Hi all,
I plan to write a shell script to inform users on their task when certain condition met.
example: If a
then email user on action a
else
email user on action b.
I'm pretty new in scripting, appreciate any suggestions.
Thanks. (4 Replies)