at which byte do two strings differ

2008-05-05 Thread Nathan Coulter
Looking for a simple ways to output the byte at which two strings differ. Here is one: cmp <(echo "hello") <(echo "help") | cut -d' ' -f5 | tr -d , Any other suggestions? -- Yorick

last element of an array

2007-05-25 Thread Nathan Coulter
The syntax I'm currently using to access the last element of an array looks a little evil: >arr=( one two three ) >echo ${arr[$(([EMAIL PROTECTED]))]} three If there is not currently a friendlier syntax for this, might I suggest: ${arr[-1]} -- Poor Yorick ___

Re: mkfifo and tee within a function

2006-11-30 Thread Nathan Coulter
> ---Original Message--- > From: Nathan Coulter <[EMAIL PROTECTED]> > Subject: Re: mkfifo and tee within a function > Sent: 2006-11-28 17:19 > I think that is true for an anonymous pipe, but not for a named pipe. > Timing is not the issue here. A command

mkfifo and tee within a function

2006-11-28 Thread Nathan Coulter
Hi, Within a function, I'd like to print some input to the terminal and at the same time store it in a fifo fostore some input in a fifo, but am getting mixed results. In this example, I thought "hello" would be output twice: $>cmd_print () { mkfifo zout ; (tee zout &); cat zout ; rm zout; }

Re: mkfifo and tee within a function

2006-11-28 Thread Nathan Coulter
> From: Andreas Schwab <[SNIP]> > Subject: Re: mkfifo and tee within a function > Sent: 2006-11-28 15:09 > > Nathan Coulter <[SNIP]> writes: > > > Could anyone please provide a few pointers on how to accomplish this, and > perhaps explain the re

mkfifo and tee within a function

2006-11-28 Thread Nathan Coulter
Hi, Within a function, I'd like to print some input to the terminal and at the same time store it in a fifo fostore some input in a fifo, but am getting mixed results. In this example, I thought "hello" would be output twice: $>cmd_print () { mkfifo zout ; (tee zout &); cat zout ; rm zout; }

Re: read command and ascii null as delimiter

2006-09-11 Thread Nathan Coulter
Chet Ramey wrote: "Nathan Coulter" <[EMAIL PROTECTED]> writes: read -d $'\0' will do most of what you want, with one limitation. The This is actually equivalent to read -d ''. So, to recap, the way to read null-delimited data

Re: read command and ascii null as delimiter

2006-09-11 Thread Nathan Coulter
> From: Chet Ramey <[EMAIL PROTECTED]> > Subject: Re: read command and ascii null as delimiter > Sent: 2006-09-08 08:49 > > Nathan Coulter wrote: > > Feature request: an option, maybe "-0" to use ascii null as the delimiter > for the "re

process null-delimited input

2006-09-07 Thread Nathan Coulter
I'd like to use a bash script in a pipe to process null-delimited output: | myscript > results Since the "read" command seems to currently be unable to use ascii null as a delimiter, I'm using xargs to parse the file and feed to a subshell: *** contents of myscript*** cat <&0 | xargs -0 -n2 b

read command and ascii null as delimiter

2006-09-05 Thread Nathan Coulter
Feature request: an option, maybe "-0" to use ascii null as the delimiter for the "read" command. It would make the following two commands produce the same output: [EMAIL PROTECTED]:~/tmp5$ printf 'hello\000there' | xargs -n1 -0 echo hello there [EMAIL PROTECTED]:~/tmp5$ printf 'hello\000there