in reply to Re: printing passwd file
in thread printing passwd file

You can also use this:

perl -wlne 'print join " ", (split /:/)[0, 4]' /etc/passwd

Replies are listed 'Best First'.
Re^3: printing passwd file
by halley (Prior) on Mar 14, 2005 at 18:09 UTC
    And arbitrarily playing golf:
    perl -lne 'print "@{[(split /:/)[0, 4]]}"' /etc/passwd
    Or particularly well suited to -a and -F:
    perl -F: -lane 'print "@F[0, 4]"' /etc/passwd

    --
    [ e d @ h a l l e y . c c ]

      Well, if you want to play golf, you can even leave out the spaces:

      perl -F: -lane 'print "@F[0, 4]"' /etc/passwd
      or leave out perl completely:
      cut -d: -f1,5 /etc/passwd|tr : \
      of which the end reminds me to this classic error message:
      $ \(- -bash: (-: command not found