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

Re: cut(1) and space delimiters



On 2010-03-19 21:54, Mike Viau wrote:
Fri, 19 Mar 2010 21:34:47 -0500 <ron.l.johnson@cox.net> wrote:
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?


Firstly I am no pro at string manipulation but the working examples seems to have no line feed characters, whereas the "dpkg --get-selections" creates a new line for every package it prints.

In Unicode (linux)

LF:    Line Feed, U+000A

I tried "dpkg --get-selections | grep -v deinstall$ | cut -d'\n' -f1"  but still had not luck though...


The newline should have no effect.  This, for example, works perfectly:

$ apt-show-versions -u | cut -d/ -f1



--
Obsession with "preserving cultural heritage" is a racist impediment
to moral, physical and intellectual progress.


Reply to: