|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
incorrectly sorted file with snow leopard sort |
|
|
Re: incorrectly sorted file with snow leopard sortOn Tuesday 03 of November 2009 19:23:18 emmanuel poirier wrote:
> Attachment: list-of-groups-greetings.txt $ cat list-of-groups-greetings.txt | tr -d "\r" | sort Kamil |
|
|
Re: incorrectly sorted file with snow leopard sort-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 According to Kamil Dudka on 11/3/2009 1:16 PM: > On Tuesday 03 of November 2009 19:23:18 emmanuel poirier wrote: >> Attachment: list-of-groups-greetings.txt > > $ cat list-of-groups-greetings.txt | tr -d "\r" | sort Useless use of cat. tr -d "\r" < list-of-groups-greetings.txt | sort - -- Don't work too hard, make some time for fun as well! Eric Blake ebb9@... -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkrw3/wACgkQ84KuGfSFAYC5igCgsh66IGswaEAoJkZV5bXd6gMV 8jYAoK7g3E/eKGlsWzqjI9egEpumOTlo =DJym -----END PGP SIGNATURE----- |
|
|
Re: incorrectly sorted file with snow leopard sort-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 According to Eric Blake on 11/3/2009 6:59 PM: > According to Kamil Dudka on 11/3/2009 1:16 PM: >> On Tuesday 03 of November 2009 19:23:18 emmanuel poirier wrote: >>> Attachment: list-of-groups-greetings.txt >> $ cat list-of-groups-greetings.txt | tr -d "\r" | sort > > Useless use of cat. > > tr -d "\r" < list-of-groups-greetings.txt | sort Also, "\r" is not portable - some shells treat it as "r", others as "\\r". For portability, use: tr -d '\r' < list-of-groups-greetings.txt | sort - -- Don't work too hard, make some time for fun as well! Eric Blake ebb9@... -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkrw4QcACgkQ84KuGfSFAYDV6QCdGC0JALmQL4N51rUeiZQK6dZX C0QAoJROHxSOjqC/PbSVW2vwQI2uKOXs =Rocb -----END PGP SIGNATURE----- |
|
|
|
|
|
Re: incorrectly sorted file with snow leopard sortEric Blake wrote on 11/04/2009 02:59 AM:
>> $ cat list-of-groups-greetings.txt | tr -d "\r" | sort > > Useless use of cat. > > tr -d "\r" < list-of-groups-greetings.txt | sort Useless maybe, but then again maybe the user won some time by it. I often wind up with constructs like this. Many times, you do 'less /path/to/file', then right after you may want to run sed or grep on it, in which case I usually find it quicker to edit the previous command-line as little as I can, and just attach the grep or sed or whatever-command to it: 'less /path/to/file | grep regex'. An many times --this may be hurtful ;-)-- I wind up doing 'cat file' on too large a file, followed by a quick command- line edit that gives me: 'cat file | less'. Basically, I think I (my fingers?, my eyes?) have trouble getting to the '<'. I'm not a touch typist by any means. bjd |
|
|
Re: incorrectly sorted file with snow leopard sortEric Blake wrote on 11/04/2009 02:59 AM:
>> $ cat list-of-groups-greetings.txt | tr -d "\r" | sort > > Useless use of cat. > > tr -d "\r" < list-of-groups-greetings.txt | sort Useless maybe, but then again maybe the user won some time by it. I often wind up with constructs like this. Many times, you do 'less /path/to/file', then right after you may want to run sed or grep on it, in which case I usually find it quicker to edit the previous command-line as little as I can, and just attach the grep or sed or whatever-command to it: 'less /path/to/file | grep regex'. And many times --this may be hurtful ;-) -- I wind up doing 'cat file' on too large a file, followed by a quick command- line edit that gives me: 'cat file | less'. Basically, I think I (my fingers?, my eyes?) have trouble getting to the '<'. I'm not a touch typist by any means. bjd |
|
|
Re: incorrectly sorted file with snow leopard sortBauke Jan Douma wrote:
> Eric Blake wrote on 11/04/2009 02:59 AM: >> Useless use of cat. >> tr -d "\r" < list-of-groups-greetings.txt | sort > > Useless maybe, but then again maybe the user won some time > by it. I often wind up with constructs like this. > > Many times, you do 'less /path/to/file', then right after you > may want to run sed or grep on it, in which case I usually > find it quicker to edit the previous command-line as little > as I can, and just attach the grep or sed or whatever-command > to it: 'less /path/to/file | grep regex'. > > An many times --this may be hurtful ;-)-- I wind up doing 'cat > file' on too large a file, followed by a quick command- > line edit that gives me: 'cat file | less'. > > Basically, I think I (my fingers?, my eyes?) have trouble > getting to the '<'. I'm not a touch typist by any means. I don't think anyone worries about anything written on the command line. If you are typing it and hitting enter then do whatever makes sense to you. The problem is that those command lines tend to make their way into scripts. It is in scripts that some of these constructs cause more problems. Doing character I/O can actually be quite CPU intensive. I have often benchmarked and found large optimizations there. It does keep those multicore processors busy! :-) Bob |
|
|
Re: incorrectly sorted file with snow leopard sortBauke Jan Douma <bjdouma@...> writes:
> Eric Blake wrote on 11/04/2009 02:59 AM: > >>> $ cat list-of-groups-greetings.txt | tr -d "\r" | sort >> >> Useless use of cat. >> >> tr -d "\r" < list-of-groups-greetings.txt | sort > > Useless maybe, but then again maybe the user won some time > by it. I often wind up with constructs like this. > > Many times, you do 'less /path/to/file', then right after you > may want to run sed or grep on it, in which case I usually > find it quicker to edit the previous command-line as little > as I can, and just attach the grep or sed or whatever-command > to it: 'less /path/to/file | grep regex'. $ < list-of-groups-greetings.txt tr -d "\r" | sort Andreas. -- Andreas Schwab, schwab@... GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." |
| Free embeddable forum powered by Nabble | Forum Help |