zsh-users
 help / color / mirror / code / Atom feed
* can I access output of locate?
@ 2015-03-13 16:23 zzapper
  2015-03-13 16:46 ` zzapper
  0 siblings, 1 reply; 6+ messages in thread
From: zzapper @ 2015-03-13 16:23 UTC (permalink / raw)
  To: zsh-users

locate my.cnf
/etc/my.cnf
/backup/my.cnf

so I could cd to say 2nd entry


-- 
zzapper
https://twitter.com/dailyzshtip

---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com



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

* Re: can I access output of locate?
  2015-03-13 16:23 can I access output of locate? zzapper
@ 2015-03-13 16:46 ` zzapper
  2015-03-13 16:49   ` Edelwin Khaelos
  0 siblings, 1 reply; 6+ messages in thread
From: zzapper @ 2015-03-13 16:46 UTC (permalink / raw)
  To: zsh-users

zzapper <david@rayninfo.co.uk> wrote in 
news:XnsA45CA6B27FC84davidrayninfocouk@80.91.229.13:

> locate my.cnf
> /etc/my.cnf
> /backup/my.cnf

In a response to a query:-
Can I load the output of locate into a zsh array



-- 
zzapper
https://twitter.com/dailyzshtip

---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com



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

* Re: can I access output of locate?
  2015-03-13 16:46 ` zzapper
@ 2015-03-13 16:49   ` Edelwin Khaelos
  2015-03-13 17:17     ` zzapper
  0 siblings, 1 reply; 6+ messages in thread
From: Edelwin Khaelos @ 2015-03-13 16:49 UTC (permalink / raw)
  To: zsh-users

yes, that's what pipes and variables are made for.

Le 13/03/2015 17:46, zzapper a écrit :
> zzapper <david@rayninfo.co.uk> wrote in
> news:XnsA45CA6B27FC84davidrayninfocouk@80.91.229.13:
>
>> locate my.cnf
>> /etc/my.cnf
>> /backup/my.cnf
>
> In a response to a query:-
> Can I load the output of locate into a zsh array
>
>
>


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

* Re: can I access output of locate?
  2015-03-13 16:49   ` Edelwin Khaelos
@ 2015-03-13 17:17     ` zzapper
  2015-03-13 19:01       ` ZyX
  0 siblings, 1 reply; 6+ messages in thread
From: zzapper @ 2015-03-13 17:17 UTC (permalink / raw)
  To: zsh-users

Edelwin Khaelos <edelwin@mailoo.org> wrote in news:55031519.9020906
@mailoo.org:
variables


# then to answer my own question
a=($(locate my.cnf))  # the outer () are important

echo ${a[1]}





-- 
zzapper
https://twitter.com/dailyzshtip

---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com



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

* Re: can I access output of locate?
  2015-03-13 17:17     ` zzapper
@ 2015-03-13 19:01       ` ZyX
  2015-03-14  3:57         ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: ZyX @ 2015-03-13 19:01 UTC (permalink / raw)
  To: zzapper, zsh-users

13.03.2015, 20:19, "zzapper" <david@rayninfo.co.uk>:
> Edelwin Khaelos <edelwin@mailoo.org> wrote in news:55031519.9020906
> @mailoo.org:
> variables
>
> # then to answer my own question
> a=($(locate my.cnf))  # the outer () are important

Now locate something with a space. This variant works only as long as you are certain you have no characters from IFS in a file name.

Thus you should use a=( ${(0)"$(locate -0 my.cnf)"} ).

>
> echo ${a[1]}
>
> --
> zzapper
> https://twitter.com/dailyzshtip
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> http://www.avast.com


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

* Re: can I access output of locate?
  2015-03-13 19:01       ` ZyX
@ 2015-03-14  3:57         ` Bart Schaefer
  0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2015-03-14  3:57 UTC (permalink / raw)
  To: zsh-users

On Mar 13, 10:01pm, ZyX wrote:
}
} Now locate something with a space. This variant works only as long as
} you are certain you have no characters from IFS in a file name.
}
} Thus you should use a=( ${(0)"$(locate -0 my.cnf)"} ).

Or

    locate -0 my.cnf | IFS=$'\0' read -A a

which might be slightly faster if there are a LOT of hits from locate.


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

end of thread, other threads:[~2015-03-14  3:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-13 16:23 can I access output of locate? zzapper
2015-03-13 16:46 ` zzapper
2015-03-13 16:49   ` Edelwin Khaelos
2015-03-13 17:17     ` zzapper
2015-03-13 19:01       ` ZyX
2015-03-14  3:57         ` Bart Schaefer

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).