:: [DNG] Awkishness [Was: Re: Steam, M…
Pàgina inicial
Delete this message
Reply to this message
Autor: dvalin
Data:  
A: dng
Assumpte: [DNG] Awkishness [Was: Re: Steam, Mumble, Valheim, Alsa and shared audio

  On 02.07.21 10:58, hal wrote:
 
  >
  > $ dpkg -l | egrep -i '(alsa|pulse)' | awk '{print $1"  "$2};'
  > ii  alsa-utils
  > ii  apulse:amd64
  ..
 
  
  Granted, the egrep as quick to use if that's what one's typing
  fingers remember, and day to day, it's only the results which
matter
  a damn. But as an aside, is it maybe generically helpful to hint
  that awk is a complete text processing language; one that it is
  not often fully utilised these days? It'll do it all:
 
 
  $ dpkg -l | awk -v IGNORECASE=1 '/alsa|pulse/ {print $1"  "$2};'
  ii  alsa-utils
  ii  debian-pulseaudio-config-override
  ii  gstreamer1.0-alsa:i386
  ii  gstreamer1.0-pulseaudio:i386

  
  That its great strength is grepping, via the "/pattern/ {action}"
  behaviour, is perhaps clearer for the casual reader when we don't
  stop to ignore case:
 
  $ dpkg -l | awk '/alsa|pulse/ {print $1"  "$2};'
  ii  alsa-utils
  ii  debian-pulseaudio-config-override
  ii  gstreamer1.0-alsa:i386
  ii  gstreamer1.0-pulseaudio:i386

  As for egrep (over plain grep), "The regular expressions in awk 
are a superset of the POSIX specification for Extended Regular
  Expressions (EREs). POSIX EREs are based on the regular 
expressions accepted by the traditional egrep utility.", quoting  the
"GAWK: Effective AWK Programming" pdf.
  Incidentally, I found the mawk variant was awk on my beowulf 
install. As I prefer to take advantage of a few enhancements
  provided by gawk (GNU Awk), I've done a quick:  # apt-get install
gawk
   I hope that interests someone. It's not often that an
opportunity  to espouse the original text Swiss army knife presents
itself.

  Erik