9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] pass list from Rc to awk (p9p vs plan9)
@ 2018-08-17  8:27 dexen deVries
  2018-08-17 12:45 ` Steve Simon
  0 siblings, 1 reply; 2+ messages in thread
From: dexen deVries @ 2018-08-17  8:27 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 244 bytes --]

mental note, as it took me a second to put it together:

#!/usr/bin/env rc

flag e +

myList = ( aa bb cc)

awk '
BEGIN {
split(ENVIRON["myList"], myList, "\001") # "\000" on plan9 proper
for (n in myList)
print n, myList[n]
}
'

[-- Attachment #2: Type: text/html, Size: 702 bytes --]

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

* Re: [9fans] pass list from Rc to awk (p9p vs plan9)
  2018-08-17  8:27 [9fans] pass list from Rc to awk (p9p vs plan9) dexen deVries
@ 2018-08-17 12:45 ` Steve Simon
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Simon @ 2018-08-17 12:45 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

cunning.

i have never used ENVIRON, using -v instead but this can cause escaping problems. this is a nice solution.

-Steve


> On 17 Aug 2018, at 09:27, dexen deVries <dexen.devries@gmail.com> wrote:
> 
> mental note, as it took me a second to put it together:
> 
> #!/usr/bin/env rc
> 
> flag e +
> 
> myList = ( aa bb cc)
> 
> awk '
> 	BEGIN {
> 		split(ENVIRON["myList"], myList, "\001")	# "\000" on plan9 proper
> 		for (n in myList)
> 			print n, myList[n]
> 	}
> '
> 




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

end of thread, other threads:[~2018-08-17 12:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-17  8:27 [9fans] pass list from Rc to awk (p9p vs plan9) dexen deVries
2018-08-17 12:45 ` Steve Simon

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