[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: cut(1) and space delimiters



Am 19. Mär, 2010 schwätzte Ron Johnson so:

Googled and followed examples, which work, but my specific problem doesn't work...

WORKS:
$ service="http mail ssh"
$ echo $service | cut -d\  -f2
mail
$ echo $service | cut -d' ' -f2
mail
dpkg --get-selections | grep -v deinstall$ | awk '{print $1}'


DOES NOT WORK:
$ dpkg --get-selections | grep -v deinstall$ | cut -d' ' -f1
$ dpkg --get-selections | grep -v deinstall$ | cut -d\  -f1


Is the problem that there's so *much* whitespace in the dpkg listing?

dpkg is outputting tabs.

Cut uses a tab as the default delimiter :).

dpkg --get-selections | grep -v deinstall$ | head -2 | cut -f1
a2ps
abook

ciao,

der.hans
--
#  http://www.LuftHans.com/Classes        http://www.TwoGeekTechs.com/
#  Director of Engineering, FonWallet Transaction Solutions, Inc.
#  "The babys blood type? Human, mostly."  -- Orson Scott Card

Reply to: