Awk by example / Awk в примерах: Part 1: An intro to the great language with the strange name

Английский оригинал Перевод на русский

Сожалеем, но текст оригинала доступен только зарегистрированным пользователям.

$1 == "fred" { print $3 }

Daemon786 06.02.11 в 19:55

0

$5 ~ /root/ { print $3 }

Daemon786 06.02.11 в 19:55

0

{
if ( $5 ~ /root/ ) {
print $3
}
}

Daemon786 06.02.11 в 19:56

0

{
if ( $1 == "foo" ) {
if ( $2 == "foo" ) {
print "uno"
} else {
print "one"
}
} else if ($1 == "bar" ) {
print "two"
} else {
print "three"
}
}

Daemon786 06.02.11 в 19:57

0

! /matchme/ { print $1 $3 $4 }

Daemon786 06.02.11 в 19:57

0

{
if ( $0 !~ /matchme/ ) {
print $1 $3 $4
}
}

Daemon786 06.02.11 в 19:58

0

( $1 == "foo" ) && ( $2 == "bar" ) { print }

Daemon786 06.02.11 в 19:59

0

BEGIN { x=0 }
/^$/ { x=x+1 }
END { print "I found " x " blank lines. :)" }

Daemon786 06.02.11 в 20:00

0

x="1.01"
# We just set x to contain the *string* "1.01"
x=x+1
# We just added one to a *string*
print x
# Incidentally, these are comments :)

Daemon786 06.02.11 в 20:01

0

2.01

Daemon786 06.02.11 в 20:02

0

{ print ($1^2)+1 }

Daemon786 06.02.11 в 20:02

0

FS="\t+"

Daemon786 06.02.11 в 20:04

0

FS="[[:space:]+]"

Daemon786 06.02.11 в 20:05

0

FS="foo[0-9][0-9][0-9]"

Daemon786 06.02.11 в 20:06

0

NF == 3 { print "this particular record has three fields: " $0 }

Daemon786 06.02.11 в 20:07

0

{
if ( NF > 2 ) {
print $1 " " $2 ":" $3
}
}

Daemon786 06.02.11 в 20:08

0

(NR < 10 ) || (NR > 100) { print "We are on record number 1-9 or 101+" }

Daemon786 06.02.11 в 20:09

0
Минутку...

← Предыдущая страница

Следующая страница →