Re: Shell mit Seltsamkeiten

From: Oliver Fromme <olli(at)lurza.secnetix.de>
Date: Mon, 17 Apr 2006 19:30:38 +0200 (CEST)

Marc Santhoff <M.Santhoff(at)t-online.de> wrote:
> $ sh -c "xwininfo -root | grep Width | awk '{print $2}' > /tmp/OOo-macrotest.txt"
> $ cat /tmp/OOo-macrotest.txt
> Width: 1600

Dollarzeichen werden auch innerhalb von doppelten Anfüh-
rungszeichen expandiert (das ist der wichtigste Unter-
schied zwischen einfachen und doppelten Anführungszeichen).
Das awk kriegt daher das »$2« nicht zu Gesicht. Du kannst
es z.B. mit einem Backslash escapen.

Außerdem ist das grep überflüssig. Mein Vorschlag:

$ sh -c "xwininfo -root | awk '/Width/{print \$2}'"
1400

Gruß
   Olli

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.
It's trivial to make fun of Microsoft products,
but it takes a real man to make them work,
and a God to make them do anything useful.
To Unsubscribe: send mail to majordomo(at)de.FreeBSD.org
with "unsubscribe de-bsd-questions" in the body of the message
Received on Mon 17 Apr 2006 - 19:31:59 CEST

search this site