zsh-users
 help / color / mirror / code / Atom feed
* Passing sentences to an array
@ 2005-07-18 13:49 zzapper
  2005-07-18 15:11 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: zzapper @ 2005-07-18 13:49 UTC (permalink / raw)
  To: zsh-users

Hi sorry me again.

filessubject=($(egrep -i "note [0-9]{3}.*$1" note???.txt))

The above instead of a creating an array where each grepped line is an array element (desired
behaviour" , creates an array of each word in each of the lines.

I haven't got word split set as an option

$ setopt
extendedglob
interactive
login
monitor
nopromptcr
shinstdin
zle
-- 
zzapper
vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
http://www.rayninfo.co.uk/tips/ vim, zsh & success tips


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Passing sentences to an array
  2005-07-18 13:49 Passing sentences to an array zzapper
@ 2005-07-18 15:11 ` Bart Schaefer
  2005-07-18 15:51   ` zzapper
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2005-07-18 15:11 UTC (permalink / raw)
  To: zsh-users

On Jul 18,  2:49pm, zzapper wrote:
}
} The above instead of a creating an array where each grepped line is an
} array element (desired behaviour" , creates an array of each word in
} each of the lines.

This one ought to be in the FAQ.

filessubject=( ${(f)"$(egrep -i 'note [0-9]{3}.*$1' note???.txt)"} )

} I haven't got word split set as an option

Doesn't matter, word splitting is the defined behavior for $(...) and
`...` substitutions.  If it were not, you'd get a one-element array,
which isn't any closer to what you wanted.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Passing sentences to an array
  2005-07-18 15:11 ` Bart Schaefer
@ 2005-07-18 15:51   ` zzapper
  0 siblings, 0 replies; 3+ messages in thread
From: zzapper @ 2005-07-18 15:51 UTC (permalink / raw)
  To: zsh-users

On Mon, 18 Jul 2005 15:11:20 +0000,  wrote:

>On Jul 18,  2:49pm, zzapper wrote:
>}
>} The above instead of a creating an array where each grepped line is an
>} array element (desired behaviour" , creates an array of each word in
>} each of the lines.
>
>This one ought to be in the FAQ.
>
>filessubject=( ${(f)"$(egrep -i 'note [0-9]{3}.*$1' note???.txt)"} )
>
Thanx vmuch Bart,
The above solution however had a quoting problem, where the single quotes were preventing $1 being
evaulated.
I evntually fixed this by creating a global alias

alias -g egrepcmd='egrep -i "note [0-9]{3}.*pink" note???.txt'
filessubject=(${(f)"$(egrepcmd)"} )
print -C 1 $filessubject

But are there any other zsh solutions to the "eternal" quoting problem

-- 
zzapper
vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
http://www.rayninfo.co.uk/tips/ vim, zsh & success tips


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-07-18 15:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-18 13:49 Passing sentences to an array zzapper
2005-07-18 15:11 ` Bart Schaefer
2005-07-18 15:51   ` zzapper

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).