Re: bug#6554: [coreutils] Additional suffix for split

2011-02-13 Thread Peng Yu
On Fri, Jul 2, 2010 at 2:51 PM, Eric Blake ebl...@redhat.com wrote: [adding bug-coreutils, to create a bug id to track this by] On 06/15/2010 09:23 PM, Peng Yu wrote: I need to add an additional common suffix to the files splited by split. Right now, I have to use mv to do so. But I feel

Faster ls when there are thousands of files in a directory

2011-06-24 Thread Peng Yu
Hi, When there are a few thousands of files/directories in a directory that I want to ls, I experience long wait time (a few seconds on mac). I'm wondering if some kind of cache can be built for ls to speed it up? Note my ls is installed from macport (not the native mac ls). -- Regards, Peng

Re: Faster ls when there are thousands of files in a directory

2011-06-25 Thread Peng Yu
On Sat, Jun 25, 2011 at 12:54 AM, Jim Meyering j...@meyering.net wrote: Peng Yu wrote: When there are a few thousands of files/directories in a directory that I want to ls, I experience long wait time (a few seconds on mac). I'm wondering if some kind of cache can be built for ls to speed

sort's --key argument

2011-06-27 Thread Peng Yu
Hi, I want to sort by the 2nd column (see the 2nd command). But it seems that it still sorts by the second column then by the first column. Does anybody know how --key works? $ cat input.txt u a c c a a e e p a m e a a l e a a $sort --key=2,2 input.txt a a a a a a p a u a c c e e l e m e $sort

Extend readlink -e

2011-11-04 Thread Peng Yu
Hi, readlink -e current returns nothing if the argument is not a symbolic link. I feel that it might be convenient to add an additional option to print the file/dir even the argument is not a symbolic link. Would the maintainer of readlink consider adding such an option? Thanks! -- Regards,

Re: Extend readlink -e

2011-11-04 Thread Peng Yu
must exist On Fri, Nov 4, 2011 at 11:17 AM, Eric Blake ebl...@redhat.com wrote: On 11/04/2011 10:15 AM, Peng Yu wrote: Hi, readlink -e current returns nothing if the argument is not a symbolic link. I feel that it might be convenient to add an additional option to print the file/dir even

Re: Extend readlink -e

2011-11-04 Thread Peng Yu
Hi Eric, I think that you might misunderstood my point. The current wording in the manual (that is, the info pages) is: `Canonicalize mode'     `readlink' outputs the absolute name of the given file which     contains no `.', `..' components nor any repeated separators (`/')     or

uniq without the need of sort

2011-11-08 Thread Peng Yu
Hi, 'uniq' currently relies on 'sort'. When the input file is small, this is OK. But when the input file is large, this seems to be a waste (the complexity is O(n log(n)), if uniq handles a hash table its self the complexity is only O(n)). I'm wondering if it is better to relax the requirement of

How to make a temp fifo?

2011-11-11 Thread Peng Yu
Hi, I'm wondering if there is a way to make a temp fifo. I could use the following to generate a temp fifo. But I'm wondering what is the safest way to generate a temp fifo. file=`mktemp -u` mkfifo $file do something rm $file -- Regards, Peng

Re: How to make a temp fifo?

2011-11-11 Thread Peng Yu
On Fri, Nov 11, 2011 at 12:38 PM, Eric Blake ebl...@redhat.com wrote: On 11/11/2011 11:36 AM, Peng Yu wrote: Hi, I'm wondering if there is a way to make a temp fifo. I could use the following to generate a temp fifo. But I'm wondering what is the safest way to generate a temp fifo. dir

Re: How to make a temp fifo?

2011-11-11 Thread Peng Yu
On Fri, Nov 11, 2011 at 12:47 PM, Eric Blake ebl...@redhat.com wrote: On 11/11/2011 11:41 AM, Peng Yu wrote: On Fri, Nov 11, 2011 at 12:38 PM, Eric Blake ebl...@redhat.com wrote: On 11/11/2011 11:36 AM, Peng Yu wrote: Hi, I'm wondering if there is a way to make a temp fifo. I could use

command for relative path

2011-11-12 Thread Peng Yu
Hi, coreutils can give abspaths ('readlink -f -e'). But I'm not able to find a command for relative paths. I use the following python script to do so. The drawback is that it is dependent on python (meaning it is less portable). But I'm wondering if it is possible to add such a command (or an

Re: command for relative path

2011-11-12 Thread Peng Yu
On Sat, Nov 12, 2011 at 12:45 PM, Eric Blake ebl...@redhat.com wrote: On 11/12/2011 09:16 AM, Peng Yu wrote: Hi, coreutils can give abspaths ('readlink -f -e'). But I'm not able to find a command for relative paths. I had to go chase down python documentation to see what you wanted, since

Re: command for relative path

2011-11-12 Thread Peng Yu
On Sat, Nov 12, 2011 at 2:41 PM, Bjartur Thorlacius svartma...@gmail.com wrote: On Sat, 12 Nov 2011 20:20:57 -, Peng Yu pengyu...@gmail.com wrote: Should this be added to an existing coreutils' command or add a new command to coreutils? Personally I'd prefer to add a command called

Re: command for relative path

2011-11-13 Thread Peng Yu
On Sun, Nov 13, 2011 at 12:45 PM, Dmitry V. Levin l...@altlinux.org wrote: Hi, On Sat, Nov 12, 2011 at 11:45:56AM -0700, Eric Blake wrote: [...] http://docs.python.org/library/os.path.html os.path.relpath(path[, start])     Return a relative filepath to path either from the current

Re: command for relative path

2011-11-13 Thread Peng Yu
would you care to submit a patch? Hi, I have finished relpath.c. When I push it (after commit), I get the following error. I'm new to git. Does anybody know what the problem is? And how to get my patch to the central git repository? ~/coreutils$ git push fatal: The remote end hung up

Re: command for relative path

2011-11-14 Thread Peng Yu
--stdout -1 DIFF ~/coreutils$ cat DIFF From fc71bbd211a7b9bb37d7a231a0507d8b8f5b14b1 Mon Sep 17 00:00:00 2001 From: Peng Yu pengyu...@gmail.com Date: Mon, 14 Nov 2011 07:03:12 -0600 Subject: [PATCH] maint: Add src/relpath.c --- src/relpath.c |1 + 1 files changed, 1 insertions(+), 0 deletions

Re: command for relative path

2011-11-14 Thread Peng Yu
2011/11/14 Pádraig Brady p...@draigbrady.com: On 11/14/2011 01:46 PM, Peng Yu wrote: However, please do us (and yourself) a favor by reading and applying the guidelines in HACKING before posting your patch. I had committed more than one times. The following command only shows the latest

PATCH: relpath

2011-11-30 Thread Peng Yu
to the repository? -- Forwarded message -- From: Peng Yu pengyu...@gmail.com Date: 2011/11/14 Subject: Re: command for relative path To: Pádraig Brady p...@draigbrady.com Cc: Coreutils coreutils@gnu.org 2011/11/14 Pádraig Brady p...@draigbrady.com: On 11/14/2011 01:46 PM, Peng Yu wrote

Re: PATCH: relpath

2011-12-01 Thread Peng Yu
realpath [-s|--strip] [-z|--zero]  filename  ... I'm not sure why you and Jim want to merge a different function under the name realpath. To me, I think this less intuitive. The English word 'real path' is different from the word 'relative path'. If 'relpath' is used, probably don't need to read

Re: PATCH: relpath

2011-12-01 Thread Peng Yu
Given there are existing realpath utils in both BSD and Debian, It is not necessarily everybody knows realpath. By default ubuntu doesn't have realpath installed. I'm not sure we should make the name less obvious than it should be just because there is a different that happen share some

Re: PATCH: relpath

2011-12-01 Thread Peng Yu
Hi Jim,    realpath --relative-start=DIR FILE ... I had some private email conversation with Eric. Per Eric's suggestion, it is better to document it to the mailing list for future reference and to make my point clearer. Just that there is a 3rd party command realpath (which doesn't have the

What does 'safely' mean in man mktemp?

2011-12-14 Thread Peng Yu
Hi, man mktemp says Create a temporary file or directory, safely, and print its name. I'm wondering what it means by safely. Does mktemp test if there is already a tempfile with the given name? If there is indeed with the same file name, will mktemp use a different name rather than overwrite

Re: What does 'safely' mean in man mktemp?

2011-12-16 Thread Peng Yu
On Wed, Dec 14, 2011 at 8:37 PM, Bob Proulx b...@proulx.com wrote: Peng Yu wrote: man mktemp says Create a temporary file or directory, safely, and print its name. I'm wondering what it means by safely. Does mktemp test if there is already a tempfile with the given name? If there is indeed

Re: What does 'safely' mean in man mktemp?

2011-12-16 Thread Peng Yu
It is a matter of perspective.  The point is that we are building a GNU operating system.  The preferred documentation format for GNU is info format not man format. I never said to get rid of info. I'm not sure what you referred to here. If you are running a non-GNU system and are only using

cat -n with different format?

2011-12-22 Thread Peng Yu
Hi, I want to change how the line number is displayed ~$ echo a | cat -n 1 a For example, I want it to be shown as 1:a Although this can be easily done in anything other scripting language, I'm wondering if there is an even easier way to get it done with cat. -- Regards, Peng

Where are MbdfghinRrV of sort -k documented?

2012-01-22 Thread Peng Yu
Hi, http://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html I don't find where MbdfghinRrV is documented. A position in a sort field specified with -k may have any of the option letters ‘MbdfghinRrV’ appended to it... Are these options documented somewhere else? --

Adding humanize_number to coreutiles?

2012-02-06 Thread Peng Yu
Hi, Several commands in coreutils have the -h option. I'm wondering whether anybody in the develop team also thinks that it is worthwhile to export it as a standalone command. If so, I'd recommend add such convenient command in coreutiles. As I don't find it anywhere else as a stand alone

uniq --accumulate

2012-02-07 Thread Peng Yu
Hi, Suppose that I have a table of the following, where the last column is a number. I'd like to accumulate the number of rows that are the same for all the remaining columns. A 1 A 3 X 2 X 3 Y 3 The result will be the following. Although this is can be easily done by awk, etc, I'm wondering if

Re: uniq --accumulate

2012-02-07 Thread Peng Yu
On Tue, Feb 7, 2012 at 10:21 AM, Assaf Gordon assafgor...@gmail.com wrote: Pádraig Brady wrote, On 02/07/2012 11:00 AM: On 02/07/2012 03:56 PM, Peng Yu wrote: Suppose that I have a table of the following, where the last column is a number. I'd like to accumulate the number of rows

Re: uniq --accumulate

2012-02-07 Thread Peng Yu
       (1)  The input file/stream should be sorted/grouped by the -grp. columns Do you actually mean that the rows are treated just like uniq does? I.e, only adjacent rows are subjected to grouping? If so, the document should be reworded to reflect this meaning. -- Regards, Peng

Re: uniq --accumulate

2012-02-07 Thread Peng Yu
       -o -ops         Specify the operation that should be applied to opCol.                        Valid operations:                            sum, count, min, max,                            mean, median, mode, antimode,                            stdev, sstdev (sample standard dev.),    

sort complexity on nearly sorted input

2012-02-11 Thread Peng Yu
Hi, I assume the time complexity of 'sort' is log N, where N is the input size. But I'm not familiar with 'sort' enough to tell the complexity of sorting a nearly sorted input. Suppose that I have a listed of N numbers, there only k numbers (k N, say k=N/100) that are not in the correct

Re: sort complexity on nearly sorted input

2012-02-11 Thread Peng Yu
On Sat, Feb 11, 2012 at 10:20 AM, Peng Yu pengyu...@gmail.com wrote: Hi, I assume the time complexity of 'sort' is log N, where N is the input size. ^ typo. Should be N log N But I'm not familiar with 'sort' enough to tell

join on multiple field

2012-02-12 Thread Peng Yu
Hi, It seems that 'join' only allow joining on 1 field. It will be very useful to allow multiple field join. Is anybody in the develop team interested in adding such a feature in join? http://lists.gnu.org/archive/html/bug-coreutils/2004-03/msg00089.html -- Regards, Peng

Re: join on multiple field

2012-02-13 Thread Peng Yu
Can't you already do this with awk? This is not a very useful comment. Everything that coreutils do can be done with some other software. Since 'join' can do 1 field join, it is natural to ask for multiple field join. After all, people use coreutils for its convenience in certain aspects. Why

How to explicte specify -t be the non-blank to blank transition?

2012-03-28 Thread Peng Yu
Hi, I don't see a way to explicit set -t to non-blank to blank transition, although implicit it is set so. Is there a way to explictly set -t to non-blank to blank transition? More general, is there a way to set the separator to other transitions? -t, --field-separator=SEP

Re: using tee with mkfifo

2012-04-27 Thread Peng Yu
On Fri, Apr 27, 2012 at 3:46 PM, Andreas Schwab sch...@linux-m68k.org wrote: Peng Yu pengyu.ut-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Hi, The following code hangs there for ever. I don't understand what is going on. Basically, I tee stdin to two named pipes and cat both pipes

Re: PATCH: relpath

2012-05-12 Thread Peng Yu
`--relative-base=BASE'     Only output relative names when both the `--relative-to' and processed     FILEs are descendants of BASE.  Otherwise output the absolute file name.     Note this option honors the @option{-m} and @option{-e} options     pertaining to file existence. '--relative-to'

Re: PATCH: relpath

2012-05-14 Thread Peng Yu
On Mon, May 14, 2012 at 3:33 AM, Pádraig Brady p...@draigbrady.com wrote: On 05/13/2012 04:27 AM, Peng Yu wrote: `--relative-base=BASE'     Only output relative names when both the `--relative-to' and processed     FILEs are descendants of BASE.  Otherwise output the absolute file name

What is the difference between --binary and the default of md5sum?

2012-07-06 Thread Peng Yu
Hi, I don't see any difference between the two md5sum commands (on Mac OS). ~/linux/test/gnu/gnu/coreutils/md5sum/--binary$ ./main.sh md5sum `which md5sum` which md5sum 02389bdcb510f7a2667f94c4264bebd8 /opt/local/libexec/gnubin/md5sum md5sum -b `which md5sum` which md5sum

Re: fifo unlimited buffer size?

2012-12-04 Thread Peng Yu
On Tue, Dec 4, 2012 at 6:24 AM, Pádraig Brady p...@draigbrady.com wrote: tag 13075 + notabug close 13075 thanks On 12/04/2012 03:19 AM, Peng Yu wrote: Hi, I have the following script. When the number to the right of 'seq' is large (as 10 in the example), the script will hang

Re: fifo unlimited buffer size? (possibly tee related)

2012-12-04 Thread Peng Yu
I understand the structure, but the concurrent pipelines need separate data sources (process or file copy), or otherwise deadlock may happen as data overflows various buffers. I suppose this could be encapsulated in tee(1) with non-blocking writes and internal buffering, but that would just

cp without overwriting files but printing warning messages automatically?

2013-03-09 Thread Peng Yu
Hi, -i can prompt warning messages. But I have to type n to avoid overwriting files. I found 'yes' to print 'y' repetitively. Is there something I can use to cp without overwrite files but with warning messages printed automatically? -- Regards, Peng

Re: cp without overwriting files but printing warning messages automatically?

2013-03-10 Thread Peng Yu
On Sun, Mar 10, 2013 at 3:37 AM, Henrik Juul Pedersen henrikj...@gmail.com wrote: Hi Peng Yu, On Sun, Mar 10, 2013 at 5:58 AM, Peng Yu pengyu...@gmail.com wrote: Hi, -i can prompt warning messages. But I have to type n to avoid overwriting files. I found 'yes' to print 'y' repetitively

Re: cp without overwriting files but printing warning messages automatically?

2013-03-10 Thread Peng Yu
On Sun, Mar 10, 2013 at 5:06 AM, CoreUtils subscribtion for PLC coreutils_at_gnu@montfranc.com wrote: yes can answer no :-D thus yes n | cp -i should do the job The warning messages are at the same line. Is there a way to make each warning message printed in a different line? mkdir -p c

Re: cp without overwriting files but printing warning messages automatically?

2013-03-10 Thread Peng Yu
On Sun, Mar 10, 2013 at 6:50 AM, CoreUtils subscribtion for PLC coreutils_at_gnu@montfranc.com wrote: sed 's/?/^n/g' or something like that ? This may not be robust when the filenames have the character '?'. -- Regards, Peng

When was stdbuf introduced?

2013-04-25 Thread Peng Yu
Hi, I see stdbuf available in coreutils. http://www.gnu.org/software/coreutils/manual/html_node/stdbuf-invocation.html But I don't find it in my system. Was stdbuf just introduced recently? Or there is something wrong with my installation? ~$ wc --version wc (GNU coreutils) 8.21 Copyright (C)

How is mv done across filesystem?

2014-01-12 Thread Peng Yu
Hi, It seems the following command across filesystem mv /filesystem1/src /filesystem2/dst is roughly equivalent to the following. The idea is that no files will be deleted from the src unless all files are correctly copied to dst. Is it so? cp -p -r /filesystem1/src /filesystem2/dst rm -rf

What is necessary and sufficient to let 'sort' sort as if strcmp in C is used?

2014-02-01 Thread Peng Yu
Hi, man sort says Set LC_ALL=C to get the traditional sort order that uses native byte values. man comm says Note, comparisons honor the rules specified by 'LC_COLLATE'. My test shows that it seems LC_COLLATE=C is sufficient to make sort using native byte values. Is it so? -- Regards, Peng

Is the command `sort input.txt -o input.txt` OK?

2014-03-15 Thread Peng Yu
Hi, `sort input.txt -o input.txt` overwrites the input file. My understanding is that sort reads everything and then write the output. So it is OK to overwrite the original file. But I want to be sure. Can anyone confirm if this is the case? Thanks. -- Regards, Peng

Why the memory usage of sort does not seem to increase as the input file size increases?

2014-05-26 Thread Peng Yu
Hi, I tried sort on some large file. But the memory usage of sort does not seem to be large. This seems to be strange to me, as I think that sort need to see all the data before completing the sorting process. Shouldn't the memory usage of sort increase as the input size increases? Thanks. --

Re: Why the memory usage of sort does not seem to increase as the input file size increases?

2014-05-26 Thread Peng Yu
Sort takes a divide and conquer approach, by sorting parts of the input to temporary files, and then merging the results with a bounded amount of memory. sort currently defaults to using a large memory buffer to minimize overhead associated with writing and reading temp files, so you may be

Is there an easy way to generate all English letters?

2014-10-04 Thread Peng Yu
Hi, seq can generate numbers easily. Is there an easy way to generate all English letters that anybody knows? -- Regards, Peng

Where are the OPTS bdfgiMhnRrV of --key of sort documented?

2014-12-25 Thread Peng Yu
Hi, I am trying to find the detailed meaning of bdfgiMhnRrV. But I can not find it in the manpage or the infopage. Does anybody know where are they documented? Thanks. -- Regards, Peng

Is there a way to inherent the permissions related with o from the parent directory?

2015-03-17 Thread Peng Yu
Hi, Is there a way to inherent the permissions related with o from the parent? For example, if the parent has the permission --- for o, when I mkdir a subdirectory, I want to subdirectory also has the permission --- for o. Is possible to somehow chmod of parent to allow this to happen? --

Re: Document for + seems to be missing in ls' document

2015-03-11 Thread Peng Yu
On Wed, Mar 11, 2015 at 4:25 PM, Eric Blake ebl...@redhat.com wrote: On 03/11/2015 03:13 PM, Peng Yu wrote: Hi, It seems that the document for ls in coreutils does not have an explanation of +. Should this be added? Thanks. http://serverfault.com/questions/227852/what-does-a-mean-at-the-end

Document for + seems to be missing in ls' document

2015-03-11 Thread Peng Yu
Hi, It seems that the document for ls in coreutils does not have an explanation of +. Should this be added? Thanks. http://serverfault.com/questions/227852/what-does-a-mean-at-the-end-of-the-permissions-from-ls-l -- Regards, Peng

Re: Document for + seems to be missing in ls' document

2015-03-13 Thread Peng Yu
That's one of the reasons that I _like_ the 'html' version of the manuals MUCH more than the 'info' version - you can choose to view the entire manual at once, at which point, a simple 'ctrl-f' will let your browser find the relevant text within the manual regardless of the 'texinfo's

-e missing for ls on Mac OS X

2015-03-12 Thread Peng Yu
Hi, Mac OS X's ls has an option -e which related with ACLs. But coreutils' ls does not have this option, which make coreutils' ls not a complete replacement of Mac OS X's ls. Is it possible to add this feature to coreutils' ls? -- Regards, Peng

Is `ls` exactly the same as `dir`?

2015-05-12 Thread Peng Yu
Hi, It seems that `ls` and `dir` are exactly the same after I read the man pages. Is it the case? -- Regards, Peng

Re: Does sort handle -t / correctly

2015-04-17 Thread Peng Yu
On Fri, Apr 17, 2015 at 11:26 AM, Eric Blake ebl...@redhat.com wrote: On 04/17/2015 10:10 AM, Peng Yu wrote: Hi, I got the following results when I call sort with -t /. It seems that 'a/1.txt' should be right after 'a'. Is it the case? Or I am not using sort correctly? Your assumption

Does sort handle -t / correctly

2015-04-17 Thread Peng Yu
Hi, I got the following results when I call sort with -t /. It seems that 'a/1.txt' should be right after 'a'. Is it the case? Or I am not using sort correctly? $ printf '%s\n' a 'a!' ab aB a/1.txt | sort -t / -k 1 -k 2 -k 3 -k 4 a a! a/1.txt aB ab -- Regards, Peng

Why cp a directory into itself still create an empty directory?

2015-06-14 Thread Peng Yu
Hi, The following code shows that cp a directory into itself still create the tmp directory in the destination. Is better not to create it? /tmp$ mkdir tmp /tmp$ $(type -P cp) -r tmp tmp /usr/local/opt/coreutils/libexec/gnubin/cp: cannot copy a directory, ‘tmp’, into itself, ‘tmp/tmp’ /tmp$ ls

What is the best way to touch a file and set its time of the last time of a bunch of other files?

2015-08-07 Thread Peng Yu
Hi, `touch -r` allows one to set the time of a file same as a reference file. What if one wants to set the time to be the last time of multiple files? Is there an easy way to do so? -- Regards, Peng

ls when some directory only has one file/dir?

2016-05-31 Thread Peng Yu
Hi, github can directly show the nested dir when a directory only has one subdir (e.g., inst/include on the following webpage). https://github.com/imbs-hl/ranger/tree/master/ranger-r-package/ranger I think that this is a good idea. Maybe this feature should be included in ls as well? --

Is there a way to specify the next business day in date?

2016-08-12 Thread Peng Yu
Hi, I don't see a way to specify the next business day in date. Does anybody see if it is possible with date? -- Regards, Peng

Does -e overrule -f in readlink?

2016-09-24 Thread Peng Yu
Hi, It seems that -e overrules -f in readlink at least according to the following. If so, when -e is specified, specification of -f does not change the result of readlink. Is it the case? tmpdir=$(mktemp -d) cd "$tmpdir" ln -s z.txt d.txt readlink -f d.txt readlink -f -e d.txt || echo "$?"

Sort differently on mac with some LC_ALL

2016-12-10 Thread Peng Yu
On mac, all the following LC_ALL result in the same results of sort. LC_ALL=en_US.UTF-8 sort <<< $'a\nb\nA\nB' A B a b LC_ALL=en_US sort <<< $'a\nb\nA\nB' A B a b LC_ALL=C sort <<< $'a\nb\nA\nB' A B a b But they are not all the same on linux. Do anybody know a LC_ALL on mac that would make sort

Is there a way to always put NA before (or after) numerical values in sort?

2017-12-08 Thread Peng Yu
Hi, I want to always put NA before (or after) numerical values being sorted. Is there a way to control this? Thanks. ~$ printf '%s\n' .1 1 NA | sort -k 1,1rg 1 .1 NA ~$ printf '%s\n' .1 1 NA | sort -k 1,1g NA .1 1 -- Regards, Peng

Re: performance bug of `wc -m`

2018-05-13 Thread Peng Yu
l.com> wrote: > Hello, > > On 12/05/18 07:55 PM, Peng Yu wrote: >> >> The following example shows that `wc -m` is even slower than the >> equivalent Python code. Can this performance bug be fixed? > > > I'm unable to reproduce the performance issue, > and suspect

performance bug of `wc -m`

2018-05-12 Thread Peng Yu
Hi, The following example shows that `wc -m` is even slower than the equivalent Python code. Can this performance bug be fixed? $ cat wcm.py #!/usr/bin/env python # vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 fileencoding=utf-8: import sys l = 0 for line in sys.stdin: l +=

Re: performance bug of `wc -m`

2018-05-13 Thread Peng Yu
om> wrote: > Hello, > > On Sun, May 13, 2018 at 09:05:47AM -0400, Peng Yu wrote: >> I am on Mac not on Linux. On Linux, I can confirm that `wc -m` is much >> faster than `wcm.py`. > > As a first step, please run "wc --version" to confirm you are using > g

Why cut treats one column input differently for out-of-range field spec?

2018-01-17 Thread Peng Yu
Hi, If there is only one column in the input, then an out-of-range field spec will result in the print of the whole line. $ cut -f 3 <<< $'a' | xxd 000: 610a a. Otherwise, an empty string is printed. $ cut -f 3 <<< $'a\tb' | xxd 000: 0a

Speed up sort with concurrency

2018-01-14 Thread Peng Yu
Hi, I see that concurrency can be used to speed up mergesort in golang. Can this be implemented in sort in coreutils? Thanks. https://medium.com/@_orcaman/when-too-much-concurrency-slows-you-down-golang-9c144ca305a -- Regards, Peng

Mapping of the special characters to the control sequences available?

2018-02-09 Thread Peng Yu
Hi, The following URL says control-v followed by control-m will insert a CR. https://superuser.com/questions/942217/how-do-i-interactively-type-r-n-terminated-query-in-netcat?answertab=active#tab-top I understand control-v is to enter the next character typed literally. And control-m is a CR.

Is there a way to print unicode characters and the actual code?

2018-02-24 Thread Peng Yu
It seems that `od` does not respect the unicode. Is there a tool (maybe different from od) that can print the code in odd lines and the unicode character in even lines? Thanks. $ od -xc <<< 'exámple' 0007865a1c3706d656c000a e x ? ? m p l e \n

Is there a way to print unicode characters and the actual code?

2018-02-24 Thread Peng Yu
I am not sure `od` respects unicode. Is there a tool (maybe different from od) that can print the code in odd lines and the unicode character in even lines? Thanks. $ od -xc <<< 'exámple' 0007865a1c3706d656c000a e x ? ? m p l e \n 011 In this

Re: Is there a way to print unicode characters and the actual code?

2018-02-24 Thread Peng Yu
> $ od -An -tx1 -ta -tc <<< 'exámple' > 65 78 c3 a1 6d 70 6c 65 0a >e x C ! m p l e nl >e x 303 241 m p l e \n At this moment, I wrote some python code to do this, which prints both the decoded code as well as the encoded code in both hex and binary

Why is `find -name '*.txt'` much slower than '*.txt' on glusterfs?

2018-01-19 Thread Peng Yu
Hi, There are ~7000 .txt files in a directory on glusterfs. Here are the run time of the following two commands. Does anybody know why the find command is much slower than *.txt. Is there a way to change the api that `find` uses to search files so that it can be more friendly to glusterfs? $

What time is `sleep` based on?

2018-03-20 Thread Peng Yu
For example, if I run `sleep 1000` and then I put the computer to sleep for 1000s and wake the computer up. Will the `sleep` finish at the time when the computer wakes up? Or `sleep` will take another 1000 seconds to terminate? Thanks. -- Regards, Peng

Understanding stdbuf

2018-11-14 Thread Peng Yu
I thought that the -oL option will wait until a line is finished in the line buffer. So I'd expect the following output of stdbuf -oL -eL ./script.sh. abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz But the actual results are interleaved. Could anybody help me understand how stdbuf works?

tail -f finish upon another process finish writing to the file

2019-01-21 Thread Peng Yu
Hi, I use tail -f to show a file as it grows. However, if the process which writes to the file is finished, tail -f will still wait there. Is there a way to let tail -f finish once it detects nobody writes to the file? Thanks. -- Regards, Peng

What tricks used in readlink to make it faster than realpath bash loadable?

2018-12-13 Thread Peng Yu
Hi, `readlink` is faster than `realpath` for a large number of input arguments. Note that the former starts slower than the latter. What tricks is used in readlink to make it faster? Thanks. https://github.com/bminor/bash/blob/master/examples/loadables/realpath.c bash> builtin enable -f

Is it possible to dd from a position in a file to the end?

2019-02-19 Thread Peng Yu
Hi, I don't see a way to specify "END" in dd. I don't want to count the length a file in another command. Is there a way to let dd dump from a given location to the end? Thanks. -- Regards, Peng

Does --parallel apply to merge sort?

2019-06-11 Thread Peng Yu
Hi, It seems that there is no need to use parallelization for merge sort. So for the following option of `sort`, I think that it only applies to regular sort by not merge sort. Is it so? --parallel=N change the number of sorts run concurrently to N -- Regards, Peng

Re: How to calculate date relative to another date?

2019-05-21 Thread Peng Yu
> Seems to work fine when date specification is not quite as ambiguous > as "2018/05". > > $ date --iso --date='2018-05-01 5 years ago' > 2013-05-01 What is special about --iso? If I use the following date string, I get a future time. Why? $ date --date='2018-05-01 4 years 11 months ago' +%Y%m

How to calculate date relative to another date?

2019-05-21 Thread Peng Yu
Hi, For example, I want to calculate 5 years less a month from May 2018, i.e., "2018/05", the result should be "2013/06". https://www.gnu.org/software/coreutils/manual/html_node/Examples-of-date.html I don't think the direct calculation of this kind of relative date is possible with coreutiles'

Why TAB in ansi color is not recognized?

2019-04-28 Thread Peng Yu
Hi, In the 2nd example, it is not sorted as what I want. Why is it so? $ printf '%s\t%s\n' a 1 a 2 |grep --color=always a | sort -k 2,2nr a 2 a 1 $ printf '%s\t%s\n' a 1 a 2 | grep --color=always a$'\t' | sort -k 2,2nr a 1 a 2 -- Regards, Peng

Re: Why TAB in ansi color is not recognized?

2019-04-28 Thread Peng Yu
Thanks. Where the `[ K` come from? I only see `[ m` but not `[ K`. What does `[ K` mean? Thanks. http://pueblo.sourceforge.net/doc/manual/ansi_color_codes.html On Sun, Apr 28, 2019 at 2:49 PM Assaf Gordon wrote: > > Hello, > > On 2019-04-28 11:23 a.m., Peng Yu wrote: > > >

How to sort and count efficiently?

2019-06-30 Thread Peng Yu
Hi, I have a long list of string (each string is in a line). I need to count the number of appearance for each string. I currently use `sort` to sort the list and then use another program to do the count. The second program doing the count needs only a small amount of the memory as the input is

Is there a way to gzip the temp file used by `sort`?

2019-07-01 Thread Peng Yu
Hi, The temp files used by `sort` are not gzipped. Is there a way to use gzip to save the space used by the temp files? Thanks. -- Regards, Peng

Re: Is there a way to gzip the temp file used by `sort`?

2019-07-01 Thread Peng Yu
Thanks. Does this option affect the -m option? Thanks. On 7/1/19, Ed wrote: > On 2019-07-01 10:44-0500, Peng Yu wrote: >> Hi, >> >> The temp files used by `sort` are not gzipped. Is there a way to use >> gzip to save the space used by the temp files? Thanks. > &g

How to print sizes of both files and directories in a directory?

2019-07-01 Thread Peng Yu
Hi, `du -h --max-depth=1` only print directory sizes. Is there a way to print the sizes of both directories and files in a directory? Thanks. -- Regards, Peng

Can -f of seq take an integer format?

2019-08-01 Thread Peng Yu
Hi, I only find %.0f to print integers. But it is just a float with no digits after the point. Is there a real integer format in seq? Thanks. $ seq -f '%.0f minutes' 2563199 2563200 2563199 minutes 2563200 minutes $ seq -f '%g minutes' 2563199 2563200 2.5632e+06 minutes 2.5632e+06 minutes

How to convert a md5sum back to a timestamp?

2019-07-31 Thread Peng Yu
Hi, Suppose that I know a md5sum that is derived one of the timestamps computed below. Is there a way to quickly derive what the original timestamp is? I could make a database of all the timestamps and their md5sums. But as the total number of entries increases, this solution will not be scalable

Re: How to sort and count efficiently?

2019-06-30 Thread Peng Yu
). On Sun, Jun 30, 2019 at 11:52 AM Assaf Gordon wrote: > Correcting myself: > > On Sun, Jun 30, 2019 at 10:08:46AM -0600, Assaf Gordon wrote: > > On Sun, Jun 30, 2019 at 07:34:19AM -0500, Peng Yu wrote: > > > > > > I have a long list of string (each string is in a line).

How to list not only content in a diretory but the directory itself as well?

2019-07-09 Thread Peng Yu
Hi `ls somedir` without -d will show the content of a directory. With -d, it will show the info of the directory itself. Is there a way to show both in a single command? Thanks. -- Regards, Peng

How to sort unicode properly?

2019-09-25 Thread Peng Yu
Hi, It seems that "café" should be sorted before "caff" in Unicode. https://github.com/jtauber/pyuca But `sort` does not do so. $ printf '%s\n' cafe caff café | LC_ALL=UTF8 sort cafe caff café $ printf '%s\n' cafe caff café | LC_ALL=en_US.UTF-8 sort cafe caff café How to make `sort` sort

Re: How to sort unicode properly?

2019-09-25 Thread Peng Yu
I want to make my `sort` to be machine-independent and always use the correct Unicode sort order. Is there a way to do so? I don't know how to check where en_US.UTF-8 comes from. Do you know how to check it? (I use Mac OS X.) On 9/25/19, Eric Blake wrote: > On 9/25/19 10:20 AM, Peng Yu wr

  1   2   >