Gentoo Archives: gentoo-user

From: "Juan Diego Tascón" <juantascon@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] is a nice "place" :-D
Date: Tue, 17 May 2011 13:53:10
Message-Id: BANLkTinNk93pSpoykPw4wAV4VH7eXqm-BQ@mail.gmail.com
In Reply to: Re: [gentoo-user] is a nice "place" :-D by Alex Schuster
1 On Tue, May 17, 2011 at 8:36 AM, Alex Schuster <wonko@×××××××××.org> wrote:
2 > Juan Diego Tascón writes:
3 >
4 >> I have always wondered if there is a way to do awk '{ print $1}' using
5 >> only builtin bash functions when you only have a one line string
6 >
7 > str="one two five"
8 >
9 > # remove all from the first blank on, but will not work with
10 > # other whitespace
11 > echo ${str%% *}
12 >
13 > or
14 >
15 > # set $1, $2, $3, ... to words of $str
16 > set $str
17 > echo $1
18 >
19 > or
20 >
21 > # create array holding one word per element
22 > strarr=( $str )
23 > echo $strarr  (or echo ${strarr[0]})
24 >
25 >        Wonko
26 >
27 >
28
29 thanks for the info