Processing Text Print

  • 0

sort, cut, awk and sed.

WHAT sort DOES

Orders lines.

WHAT THE USEFUL OPTIONS ARE

Numeric ordering Reverse Unique By a specific field

WHY NUMERIC MATTERS

Without it, ten sorts before two.

WHAT uniq DOES

Collapses adjacent duplicate lines, optionally counting them.

WHY IT MUST FOLLOW sort

It only compares neighbours.

WHAT THE COUNTING COMBINATION ACHIEVES

A frequency list, which answers most log questions.

WHAT cut DOES

Extracts fields by delimiter or position.

WHAT awk DOES

Processes lines as fields, with logic.

WHAT ITS SIMPLEST USE IS

Printing a chosen column.

WHY THAT ALONE JUSTIFIES LEARNING IT

Most log analysis is selecting one column and counting it.

WHAT sed DOES

Edits a stream, most often substituting text.

WHAT THE SUBSTITUTION FORM IS

s, then the pattern, the replacement, and flags, separated by slashes.

WHAT THE IN-PLACE OPTION DOES

Modifies the file directly.

WHY THAT DESERVES CAUTION

There is no undo, and a wrong pattern can corrupt every matched file.

WHAT TO DO FIRST

Run it without the in-place option and read the output.

WHAT TO ALWAYS KEEP

A backup, which the in-place option can create for you.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot