I've been trying to decipher your awk command but I'm a little stuck - I understand that the "? :" provides a conditional operator that is found in the C programming language - that has the form:
For the expression do one or the other depending whether the expression is matched or not e.g.
But the bit I don't understand is the expression:
I can see that you're loading $1 into an array and incrementing it... but I really don't know what you're using it for and the second part on the other side of the OR clause is even more confusing
I hope you can explain it to me - I'd really appreciate it
Hello,
I need experts help in converting the below tcl function to korn shell function equivalent.
proc lsNetMaskToBits {mask} {
set dw ; # Top N bits set
set dw 0x ; # Make sure it's hexadecimal, else XOR fails.
puts "lsNetMaskToBits dw $dw"
set dw ; # Complement => low 32-N bits... (1 Reply)
I always find BASH easier than ksh. At my home, i have written this bash script. I am finding it hard to write its equivalent in ksh, any suggestions?
######################################
#return seconds since `00:00:00 1970-01-01 UTC' (a GNU extension)... (1 Reply)
Hi,
I 'd like to translate this command from awk to findstr on Windows DOS
FILE:
str1 server1 a
str1 server2 a
str2 server1 b
str2 server2 b
Awk command:
awk ' $1 ~/str1/ { print $2, $3 } ' file.txt
OUTPUT:
server1 a
server2 a
Thanks, (1 Reply)
Hi all,
Can someone tell me what's the (g)awk equal of this simple regex to find ip addresses in urls:
egrep "^http://{1,3}\.{1,3}\.{1,3}\.{1,3}(:{1,5})?/"Input:
http://10.0.0.1/query.exe
http://11y10x09w:80/howaboutme
http://192.168.100.190:1234/takeme.gpg
Output:... (8 Replies)
Hello,
I searched online; it seems that perl use $NR as NR in awk; however it does not work for me. For example, how to re-write the following awk using perl:
awk '{ print NR}' inputfile---------- Post updated at 01:55 PM ---------- Previous update was at 12:49 PM ----------
I found... (2 Replies)
Hi all !
whether anyone in forum knows what awk will use while printing number of fields in file(NF) ?
for example
awk END'{print NF}' file
prints number of columns in file
if anyone knows equivalent code in C kindly share or explain logic behind it (8 Replies)
Hi all
Does anyone know Java-Arrays.binarySearch function equivalent in awk
I tried like this but it's not correct one,it just returns array index if and only when searched value available in array, for some reason if searched value not found then I want to return upper nearest neighbour index.... (1 Reply)
Hello. I wrote some code for an awk command but I want to learn to turn it into an awk script but am stuck. I have a file (data.csv) that has the following data:
ADD,1,3,5,8,10,11,54
SUB,1,2,3,4
ADD,15,18,21,42,37
ADD,1,1,1,0,0,3,16
ADD,4,1,8,0,4,6,13,16,17,20,8,6,4
SUB,13,8If the line... (5 Replies)
Discussion started by: Eric7giants
5 Replies
LEARN ABOUT CENTOS
if
if(n) Tcl Built-In Commands if(n)
__________________________________________________________________________________________________________________________________________________NAME
if - Execute scripts conditionally
SYNOPSIS
if expr1 ?then? body1 elseif expr2 ?then? body2 elseif ... ?else? ?bodyN?
_________________________________________________________________DESCRIPTION
The if command evaluates expr1 as an expression (in the same way that expr evaluates its argument). The value of the expression must be a
boolean (a numeric value, where 0 is false and anything is true, or a string value such as true or yes for true and false or no for false);
if it is true then body1 is executed by passing it to the Tcl interpreter. Otherwise expr2 is evaluated as an expression and if it is true
then body2 is executed, and so on. If none of the expressions evaluates to true then bodyN is executed. The then and else arguments are
optional "noise words" to make the command easier to read. There may be any number of elseif clauses, including zero. BodyN may also be
omitted as long as else is omitted too. The return value from the command is the result of the body script that was executed, or an empty
string if none of the expressions was non-zero and there was no bodyN.
EXAMPLES
A simple conditional:
if {$vbl == 1} { puts "vbl is one" }
With an else-clause:
if {$vbl == 1} {
puts "vbl is one"
} else {
puts "vbl is not one"
}
With an elseif-clause too:
if {$vbl == 1} {
puts "vbl is one"
} elseif {$vbl == 2} {
puts "vbl is two"
} else {
puts "vbl is not one or two"
}
Remember, expressions can be multi-line, but in that case it can be a good idea to use the optional then keyword for clarity:
if {
$vbl == 1 || $vbl == 2 || $vbl == 3
} then {
puts "vbl is one, two or three"
}
SEE ALSO
expr(n), for(n), foreach(n)
KEYWORDS
boolean, conditional, else, false, if, true
Tcl if(n)