Gentoo Archives: gentoo-user

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

Replies

Subject Author
Re: [gentoo-user] is a nice "place" :-D "Juan Diego Tascón" <juantascon@×××××.com>
Re: [gentoo-user] is a nice "place" :-D Pandu Poluan <pandu@××××××.info>