Activity

  • admin posted an update 5 years ago

    Display a block of text with AWK Using awk – awk ‘/start_pattern/,/stop_pattern/’ file.txt – (Display a block of text with AWK I find this terribly useful for grepping through a file, looking for just a block of text. There’s \”grep -A # pattern file.txt\” to see a specific number of lines following your pattern, but what if you want to see the whole block? Say, the output of \”dmidecode\” (as root): $ dmidecode | awk ‘/Battery/,/^$/’ Will show me everything following the battery block up to the next block of text. Again, I find this extremely useful when I want to see whole blocks of text based on a pattern, and I don’t care to see the rest of the data in output. This could be used against the ‘/etc/securetty/user’ file on Unix to find the block of a specific user. It could be used against VirtualHosts or Directories on Apache to find specific definitions. The scenarios go on for any text formatted in a block fashion. Very handy.). The best command line collection on the internet, submit yours and save your favorites.

PC Knowledge sharetank

Skip to toolbar