-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Boyd Stephen Smith Jr." <b...@iguanasuicide.net> writes:

> In <87mxzvg816....@merciadriluca-station.merciadriluca>, Merciadri Luca wrote:
>>"Boyd Stephen Smith Jr." <b...@iguanasuicide.net> writes:
>>> nl values | sort -k2 | nl | grep value_i
>>>
>>> The first column is the new location, 1-based.  The second column is the
>>> old location, 1-based.  If your values are numbers, you might use (awk '$3
>>> == value_i') instead of the grep.
>>>
>>> nl = O(n)
>>> sort = O(n lg n)
>>> grep = O(n)
>>>
>>> The whole pipeline is therefore O(n lg n).
>>
>>Would not something like
>>
>>==
>>cat file.txt | awk -F" " '{ print $0,$(
>>for ((i = 1; i < n + 1; i++))
>>do
>>echo $i
>>done
>>) }'
>>==
>>do the trick, file.txt being a text file such as
>>
>>==
>> 20 Jan 2010 17:39:42
>> .
>> .
>> .
>>==
>
> Why don't you just test your code?
>
> I don't think that awk program does what you want though.
>
> My pipeline will work on any data values without whitespace.  If you need to 
> handle whitespace, add -f "$(printf '\t')" to the sort command-line, which 
> should handle everything but tabs and newlines.  If you also need to handle 
> tabs, you can probably use -k 2,9999 instead of -k2 on the sort command-line.
You are right. Your solution is nice, effectively. Thanks.

- -- 
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- -- 

Don't try to teach a pig to sing. It doesn't work, and you'll annoy
  the pig. 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAktkYOkACgkQM0LLzLt8MhwgAgCglMQJEdaQaELlXUTomWXZ3+bq
Co0AnA+pUTc2Qp3xX3bp5hzvM4xomRKb
=T8PI
-----END PGP SIGNATURE-----


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to