From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QMLN1-0004Lc-UM for garchives@archives.gentoo.org; Tue, 17 May 2011 14:35:36 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C73911C0BE; Tue, 17 May 2011 14:34:11 +0000 (UTC) Received: from svr-us4.tirtonadi.com (unknown [69.65.43.212]) by pigeon.gentoo.org (Postfix) with ESMTP id A38971C0BE for ; Tue, 17 May 2011 14:34:11 +0000 (UTC) Received: from mail-iy0-f181.google.com ([209.85.210.181]) by svr-us4.tirtonadi.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.69) (envelope-from ) id 1QMLLp-0030CC-S8 for gentoo-user@lists.gentoo.org; Tue, 17 May 2011 21:34:21 +0700 Received: by iyb26 with SMTP id 26so602240iyb.40 for ; Tue, 17 May 2011 07:34:08 -0700 (PDT) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Received: by 10.42.131.199 with SMTP id a7mr874000ict.54.1305642848329; Tue, 17 May 2011 07:34:08 -0700 (PDT) Received: by 10.42.227.198 with HTTP; Tue, 17 May 2011 07:34:08 -0700 (PDT) In-Reply-To: <201105171536.26328.wonko@wonkology.org> References: <4DD1AEC8.5010501@earthlink.net> <201105171536.26328.wonko@wonkology.org> Date: Tue, 17 May 2011 21:34:08 +0700 Message-ID: Subject: Re: [gentoo-user] is a nice "place" :-D From: Pandu Poluan To: gentoo-user@lists.gentoo.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - svr-us4.tirtonadi.com X-AntiAbuse: Original Domain - lists.gentoo.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - poluan.info X-Archives-Salt: X-Archives-Hash: 2427da3a87219a49d66082c8bf709686 On 2011-05-17, Alex Schuster wrote: > Juan Diego Tasc=C3=B3n writes: > >> I have always wondered if there is a way to do awk '{ print $1}' using >> only builtin bash functions when you only have a one line string > > str=3D"one two five" > > # remove all from the first blank on, but will not work with > # other whitespace > echo ${str%% *} > > or > > # set $1, $2, $3, ... to words of $str > set $str > echo $1 > > or > > # create array holding one word per element > strarr=3D( $str ) > echo $strarr (or echo ${strarr[0]}) > > Wonko > > How about this: str=3D"one two three" read word etc <<< "$str" echo $word (not tested, though) -- Pandu E Poluan - IT Optimizer My website: http://pandu.poluan.info/