Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.unix.shell > #4222

Re: how to get arguments in a function split according to certain delimiters?

From "Chris F.A. Johnson" <cfajohnson@gmail.com>
Newsgroups comp.unix.shell
Subject Re: how to get arguments in a function split according to certain delimiters?
Date 2012-02-27 15:37 -0500
Organization A noiseless patient Spider
Message-ID <856t19-anp.ln1@cjlocal.com> (permalink)
References <97de1354-edd8-4eec-a660-8e921f55b326@s7g2000vby.googlegroups.com>

Show all headers | View raw


On 2012-02-27, Selva wrote:
> bash-3.2$ set | grep IFS
> IFS=:
> bash-3.2$ echo jungles:of:brazil
> jungles:of:brazil
>
>
> I want echo to get the arguments: 1=jungles, 2=of, 3=brazil

rainforest=jungles:of:brazil

IFS=: read a b c dzhunk <<EOF
$rainforest
EOF
printf "%s\n" "$a" "$b" "$c"

  OR:

IFS=:
set -f
set -- $rainforest
printf "%s\n" "$1" "$2" "$3"

  ...

-- 
   Chris F.A. Johnson, author           <http://shell.cfajohnson.com/>
   ===================================================================
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)

Back to comp.unix.shell | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

how to get arguments in a function split according to certain delimiters? Selva <kobu.selva@gmail.com> - 2012-02-26 21:49 -0800
  Re: how to get arguments in a function split according to certain delimiters? Barry Margolin <barmar@alum.mit.edu> - 2012-02-27 01:42 -0500
    Re: how to get arguments in a function split according to certain delimiters? Paul Branon <paulbranon@googlemail.com> - 2012-02-27 03:20 -0800
      Re: how to get arguments in a function split according to certain delimiters? "Mirko K." <mirkok.lists@googlemail.com> - 2012-02-27 13:35 +0100
      Re: how to get arguments in a function split according to certain delimiters? Janis Papanagnou <janis_papanagnou@hotmail.com> - 2012-02-27 13:38 +0100
      Re: how to get arguments in a function split according to certain delimiters? Paul Branon <paulbranon@googlemail.com> - 2012-02-27 05:26 -0800
        Re: how to get arguments in a function split according to certain delimiters? Barry Margolin <barmar@alum.mit.edu> - 2012-02-27 11:25 -0500
  Re: how to get arguments in a function split according to certain delimiters? Paul Branon <paulbranon@googlemail.com> - 2012-02-27 03:24 -0800
    Re: how to get arguments in a function split according to certain delimiters? Paul Branon <paulbranon@googlemail.com> - 2012-02-27 03:27 -0800
  Re: how to get arguments in a function split according to certain delimiters? "Chris F.A. Johnson" <cfajohnson@gmail.com> - 2012-02-27 15:37 -0500
    Re: how to get arguments in a function split according to certain delimiters? Selva <kobu.selva@gmail.com> - 2012-02-27 20:09 -0800
      Re: how to get arguments in a function split according to certain delimiters? Kaz Kylheku <kaz@kylheku.com> - 2012-02-28 05:44 +0000
        Re: how to get arguments in a function split according to certain delimiters? Martin Vaeth <vaeth@mathematik.uni-wuerzburg.de> - 2012-02-28 13:31 +0000

csiph-web