Prev: ===Christian Louboutin - www.vipchristianlouboutin.com
Next: sending characters to the standard input while a program is running
From: Geoff Clare on 5 Aug 2010 08:47 Atropo wrote: > 26-03-2009 P > 26-03-2009 B > 26-03-2009 R > 26-03-2009 L > 26-03-2009 O > i'm not quite > sure about the uniq -f 2. it shows 26-03-2009 P It will output just the first line of any file that has at most two fields on all lines (and either no blanks or identical blanks after the second field). That's because -f 2 tells uniq to ignore the first two fields. $ printf 'a b\nc d\n' | uniq -f 2 a b $ printf 'a b \nc d\n' | uniq -f 2 | sed -n l a b $ c d$ -- Geoff Clare <netnews(a)gclare.org.uk>
From: thdyoung on 5 Aug 2010 16:52 Thank you Janis. A lot to think about it. Tom The input will *not* "go into the array". We could say that the _index_ will go into the array. If there's already an array element created by this index (or key), not other one will be created. You can access only one element by one key. > The contents of the array aren't necessarily lost when the next line > of input is processed (the persistence of the array contents is just > a given I guess tho' it's slightly puzzling since I don't understand > awk's ability to remember). There's no "second incarnation" of an array key or of an array element.
From: Ed Morton on 5 Aug 2010 19:59 On Aug 5, 3:52 pm, "thdyo...(a)googlemail.com" <thdyo...(a)gmail.com> wrote: > Thank you Janis. > > A lot to think about it. Try this: array = hotel index = room number memory where an element is stored = room element = bed You can't have a hotel with 2 rooms with identical numbers, but you can have identical beds in multiple rooms. Ed.
From: thdyoung on 6 Aug 2010 09:20 On Aug 6, 12:59 am, Ed Morton <mortons...(a)gmail.com> wrote: > On Aug 5, 3:52 pm, "thdyo...(a)googlemail.com" <thdyo...(a)gmail.com> > wrote: > > > Thank you Janis. But isn't Janis saying - "you can't have a different room number when the bed in it is identical to another one" ? That's why the array length stays the same for lines of input w the same first field. Tom > > > A lot to think about it. > > Try this: > > array = hotel > index = room number > memory where an element is stored = room > element = bed > > You can't have a hotel with 2 rooms with identical numbers, but you > can have identical beds in multiple rooms. > > Ed.
From: Janis Papanagnou on 6 Aug 2010 09:34
On 06/08/10 15:20, thdyoung(a)googlemail.com wrote: > On Aug 6, 12:59 am, Ed Morton <mortons...(a)gmail.com> wrote: >> On Aug 5, 3:52 pm, "thdyo...(a)googlemail.com" <thdyo...(a)gmail.com> >> wrote: >> >>> Thank you Janis. > But isn't Janis saying - "you can't have a different room number when > the bed in it is identical to another one" ? That's why the array > length stays the same for lines of input w the same first field. (I was not talking about rooms. :-) To address an associative awk array you have exactly one key, and you have exactly one place (per key) to store a value that is then associated with that key. Janis > > Tom > >> >>> A lot to think about it. >> >> Try this: >> >> array = hotel >> index = room number >> memory where an element is stored = room >> element = bed >> >> You can't have a hotel with 2 rooms with identical numbers, but you >> can have identical beds in multiple rooms. >> >> Ed. > |