Skip to main content
Detailed explanation.
Source Link
Johan
  • 4.2k
  • 3
  • 25
  • 31

awk ignores leading blanks when assigning fields. The default command is print.

awk '$1 ~ /^Linux1/'

Is what you want.

Detailed explanation:

  • $1 tells awk to look at the first "column".
  • ~ tells awk to do a RegularExpression match /..../ is a Regular expression.
  • Within the RE is the string Linux and the special character ^.
  • ^ causes the RE to match from the start (as opposed to matching anywhere in the line).

Seen together: Awk will match a regular expression with "Linux" at the start of the first column.

awk ignores leading blanks when assigning fields. The default command is print.

awk '$1 ~ /^Linux1/'

Is what you want.

awk ignores leading blanks when assigning fields. The default command is print.

awk '$1 ~ /^Linux1/'

Is what you want.

Detailed explanation:

  • $1 tells awk to look at the first "column".
  • ~ tells awk to do a RegularExpression match /..../ is a Regular expression.
  • Within the RE is the string Linux and the special character ^.
  • ^ causes the RE to match from the start (as opposed to matching anywhere in the line).

Seen together: Awk will match a regular expression with "Linux" at the start of the first column.

When considering the fields, awk ignores leading space
Source Link
Johan
  • 4.2k
  • 3
  • 25
  • 31

awk ignores leading blanks when assigning fields. The default command is print.

awk ''$1 ~ /^Linux1/'

Is what you want.

awk ignores leading blanks. The default command is print.

awk '/^Linux1/'

Is what you want.

awk ignores leading blanks when assigning fields. The default command is print.

awk '$1 ~ /^Linux1/'

Is what you want.

Source Link
Johan
  • 4.2k
  • 3
  • 25
  • 31

awk ignores leading blanks. The default command is print.

awk '/^Linux1/'

Is what you want.