Re: How to get the current time in time zone represented by strings like +0100?

2024-05-16 Thread Peng Yu
> Yes. I think you will find this is all described in the manual at > https://www.gnu.org/software/coreutils/manual/html_node/Specifying-time-zone-rules.html """ ‘TZ="<+0530>-5:30"’ says that the time zone abbreviation is ‘+0530’ and the time zone is 5 hours 30 minutes east of Greenwich. """ The

Re: How to get the current time in time zone represented by strings like +0100?

2024-05-16 Thread Peng Yu
Thu May 16 11:28:06 XXX 2024 On Thu, May 16, 2024 at 8:24 AM Peng Yu wrote: > > On Wed, May 15, 2024 at 12:04 AM Grisha Levit wrote: > > > > On Tue, May 14 2024 at 16:05 Peng Yu wrote: > > > For example, in the time zone represented by +0100, how to get its >

Re: How to get the current time in time zone represented by strings like +0100?

2024-05-16 Thread Peng Yu
On Wed, May 15, 2024 at 12:04 AM Grisha Levit wrote: > > On Tue, May 14 2024 at 16:05 Peng Yu wrote: > > For example, in the time zone represented by +0100, how to get its > > current time from date using '+0100' as input? Thanks. > > Use the offset to create a t

How to get the current time in time zone represented by strings like +0100?

2024-05-14 Thread Peng Yu
Hi, For example, in the time zone represented by +0100, how to get its current time from date using '+0100' as input? Thanks. -- Regards, Peng

Re: mkdir -p competition on the same directory?

2023-02-09 Thread Peng Yu
system call of mkdir. But since they find the target is already created and is a directory, they will not complain about the error system call mkdir. That is why I never see an error similar to that of bash loadable `mkdir -p`. Is it so? On 2/9/23, Pádraig Brady wrote: > On 09/02/2023 14:57,

mkdir -p competition on the same directory?

2023-02-09 Thread Peng Yu
https://lists.gnu.org/archive/html/help-bash/2023-02/msg00053.html Bash loadable `mkdir -p` has a problem when multiple loadable `mkdir -p` is called on the same directory simultaneously. But I never see coreutils' `mkdir -p` has the same problem. Does coreutils' `mkdir -p` do something extra to

How to make mv -i return non zero status when uses choose n?

2023-01-07 Thread Peng Yu
Hi, When I use mv -i and choose n so that the destination will not be overwritten, the return status is still zero. Is there a way to let mv return nonzero status to reflect that n is chosen by the user? Thanks. -- Regards, Peng

How to count the last line when it does not end with a newline character?

2021-09-04 Thread Peng Yu
I got 1 instead of 2 in the following example. How to count the last even when it does not end with a newline character? Thanks. $ printf 'a\nb'|wc -l 1 -- Regards, Peng

Re: how to speed up sort for partially sorted input?

2021-08-11 Thread Peng Yu
On Wed, Aug 11, 2021 at 1:43 PM Kaz Kylheku (Coreutils) <962-396-1...@kylheku.com> wrote: > > On 2021-08-11 05:03, Peng Yu wrote: > > On Wed, Aug 11, 2021 at 5:29 AM Carl Edquist > > wrote: > >> (With just a bit more work, you can do all your sorting in a single &

Re: how to speed up sort for partially sorted input?

2021-08-11 Thread Peng Yu
On Wed, Aug 11, 2021 at 5:29 AM Carl Edquist wrote: > > On Tue, 10 Aug 2021, Kaz Kylheku (Coreutils) wrote: > > > On 2021-08-07 17:46, Peng Yu wrote: > >> Hi, > >> > >> Suppose that I want to sort an input by column 1 and column 2 (column > >

how to speed up sort for partially sorted input?

2021-08-07 Thread Peng Yu
Hi, Suppose that I want to sort an input by column 1 and column 2 (column 1 is of a higher priority than column 2). The input is already sorted by column1. Is there a way to speed up the sort (compared with not knowing column 1 is already sorted)? Thanks. -- Regards, Peng

How to get the past Mon/Tue/.. not after the current date?

2021-07-20 Thread Peng Yu
Hi, $ date -d 'last Tue' +%Y-%m-%d 2021-07-13 $ date +%Y-%m-%d 2021-07-20 $ date -d 'last Mon' +%Y-%m-%d 2021-07-19 I want to get the last day of week not in the future. In the above example, I want to get this Tue (2021-07-20) instead the last Tue (2021-07-13). But for Mon, I want to get 2021-07

od and UTF-8

2021-04-01 Thread Peng Yu
Hi, I am wondering whether there is a way to do something similar to od, but respect UTF-8 characters. For example, instead of print this, $ od -c -t x1 -Ax <<< α 00 � � \n ce b1 0a 03 I want to print this. Basically, if it is a printable UTF that does not require escape,

make ls -l dir1 dir2 in the same order as dir1,2 are specified

2021-03-26 Thread Peng Yu
Hi, When I try `ls -l dir1 dir2`, the order of dir1 and dir2 in the output is not necessarily the same as the input. How to make it the same as the input order? Thanks. -- Regards, Peng

Re: differece between mkfifo and mknod ... p

2021-03-24 Thread Peng Yu
On Wed, Mar 24, 2021 at 4:52 PM Bob Proulx wrote: > > Peng Yu wrote: > > It seems that both `mkfifo` and `mknod ... p` can create a fifo. What > > is the difference between them? Thanks. > > The mknod utility existed "for a decade" in Unix (don't quote me

Print modification time in compact form

2021-03-15 Thread Peng Yu
Hi, I see modification time can be printed in this format. $ stat -c '%y' file.txt 2017-07-31 17:50:54.0 +0100 Is there a way to directly print it as 20170731-1750? Thanks. -- Regards, Peng

Re: differece between mkfifo and mknod ... p

2021-03-13 Thread Peng Yu
cfb88 /* 69 vars > */) = 0 > mknod("mkfifo", S_IFIFO|0666) = 0 > > $ ls -l mk* > prw-r--r-- 1 steeve steeve 0 Mar 13 08:45 mkfifo > prw-r--r-- 1 steeve steeve 0 Mar 13 08:45 mknod > > > > On Sat, Mar 13, 2021 at 8:38 AM Peng Yu wrote: > >&g

differece between mkfifo and mknod ... p

2021-03-12 Thread Peng Yu
Hi, It seems that both `mkfifo` and `mknod ... p` can create a fifo. What is the difference between them? Thanks. -- Regards, Peng

How to ensure UTF-8 sort?

2020-12-06 Thread Peng Yu
Hi, I want to make sure sort is always use UTF-8. But I am not sure what locale is universally available on all OSes. Does anybody know what is the correct way to make sure sort by UTF-8 in all machines that coreutils is installed? Thanks. -- Regards, Peng

Better support of timezone abbreviation in `date`?

2020-10-09 Thread Peng Yu
Hi, It looks like some time zone abbreviations are not supported by `date`. For example, THA is not supported. Can a more comprehensive support be added? Thanks. https://www.timeanddate.com/time/zone/thailand -- Regards, Peng

What timezone strings are supported by `date`?

2020-10-09 Thread Peng Yu
Hi, It seems that time zone string like CET, PST are supported by `date`. But I don't find a complete list of such strings supported by `date`. Is there a doc that describe all of them? Thanks. -- Regards, Peng

What is the interpretation of bs of dd in terms of predicting the disk performance of other I/O bound programs?

2020-09-23 Thread Peng Yu
Hi, Many people use dd to test disk performance. There is a key option dd, which I understand what it literally means. But it is not clear how there performance measured by dd using a specific bs maps to the disk performance of other I/O bound programs. Could you anybody let me know the interpreta

Re: How tail works on a large file?

2020-08-22 Thread Peng Yu
Do you mean that I need to run `hexedit the_large_file`. What is the purpose of this? I don't quite understand. On 8/22/20, Budi wrote: > use wxHexEditor or Curses Hexedit > hit End to bring us to the tail > > On 8/22/20, Peng Yu wrote: >> Hi, >> >> I tried

How tail works on a large file?

2020-08-22 Thread Peng Yu
Hi, I tried to tail a large file (2.8GB) to get is last 10 lines. It runs very fast. How is this achieved? Does tail do it differently between a file (random disk access) and a pipe (sequential disk access)? Thanks. -- Regards, Peng

../.. resolution of ls

2020-06-07 Thread Peng Yu
Hi, It seems that ../../ can not be resolved symbolically by ls. See the following example. I'd like `ls ..` to print both a and b. Unfortunately, it only print b because it thinks it is in /tmp/i/a/b instead of /tmp/i/b. Is there a way to use symbolic pwd instead of abs pwd? Thanks. /tmp/i$ tree

Re: Does -s apply to -m in sort?

2020-05-11 Thread Peng Yu
Are you the author of -m? If not, maybe the author of -m should knows how it works with -s? If not, maybe this should be documented anyway? On Mon, May 11, 2020 at 5:01 PM Eric Blake wrote: > On 5/11/20 4:18 PM, Peng Yu wrote: > > I used real files (already sorted) to test whether hav

Re: Does -s apply to -m in sort?

2020-05-11 Thread Peng Yu
to authors who made -m and -s. My question should be clear? On 5/11/20, Eric Blake wrote: > On 5/9/20 4:31 PM, Peng Yu wrote: >> It seems that -s of sort is not useful when -m is used based on my >> simple test case. But I am not completely sure. Could anybody let me >> kno

Does -s apply to -m in sort?

2020-05-09 Thread Peng Yu
It seems that -s of sort is not useful when -m is used based on my simple test case. But I am not completely sure. Could anybody let me know if this is the case? Thanks. -- Regards, Peng

How to ls a directory with the directory path prepended?

2020-04-27 Thread Peng Yu
When I `ls` a directory, the content will be shown without the directory path. Is there an option of `ls` to prepend the directory path? Note that I am not looking for this way, as it involves shell. ls d/* Thanks. -- Regards, Peng

Which sha sum is the fastest?

2020-04-27 Thread Peng Yu
I got the following run time on a file of 116M. They are ranked in this order. Is this runtime order in general true? sha1sum < sha384sum <~ sha512sum < sha256sum <~ sha224sum ==> sha1sum <== real0m0.330s user0m0.275s sys 0m0.042s ==> sha224sum <== real0m0.679s user0m0.640s

altchars for base64

2020-03-14 Thread Peng Yu
Hi, Python base64 decoder has the altchars option. https://docs.python.org/3/library/base64.html base64.b64decode(s, altchars=None, validate=False)¶ But I don't see such an option in coreutils' base64. Can this option be added? Thanks. -- Regards, Peng

sort by hex number?

2020-03-05 Thread Peng Yu
I have a TSV file with a column in hex format, e.g., 0x1a000, 0x17000, 0xe000. Is there a way to sort the rows by this column in hex? Thanks. -- Regards, Peng

Re: What is the difference between unlink and rm -f?

2020-01-29 Thread Peng Yu
So a one-line summary is When the target can be delete, unlink and rm -f are the same; otherwise, unlink will complain about the error and exit with 1, but rm -f will do neither. On 1/29/20, Kaz Kylheku (Coreutils) <962-396-1...@kylheku.com> wrote: > On 2020-01-29 01:45, Peng Yu wro

Re: Show directory time as the latest time of the file in the directory (including subdirs)

2020-01-29 Thread Peng Yu
No. -t just shows the time of the directory itself. I want a summary time which is the latest time of all the contents (including the ones in the subdirecties, subsubdirs,...) in the directory. On 1/29/20, Bernhard Voelker wrote: > On 1/29/20 10:58 AM, Peng Yu wrote: >> Hi, >> >

Show directory time as the latest time of the file in the directory (including subdirs)

2020-01-29 Thread Peng Yu
Hi, For directories, ls shows in the time of the directory itself. Sometimes, it is more important to show the latest time of files in the directory in addition to the directory time. Is there an easy way to show such information? Thanks. -- Regards, Peng

What is the difference between unlink and rm -f?

2020-01-29 Thread Peng Yu
Hi, It seems to me unlink and rm -f are the same if the goal is the delete files. When are they different? Thanks. -- Regards, Peng

how to use touch to change change time?

2020-01-19 Thread Peng Yu
Hi, I don't see how to change change time by touch. Is it possible with touch? Thanks. --time=WORD change the specified time: WORD is access, atime, or use: equiv- alent to -a WORD is modify or mtime: equivalent to -m -- Regards, Peng

Re: How to implement the V comparsion used by sort in python?

2019-10-26 Thread Peng Yu
Are you sure they are 100% compatible with V? I don’t want to use them just later find they are not 100% compatible. On Sat, Oct 26, 2019 at 4:24 PM Assaf Gordon wrote: > Hello, > > > On Oct 25, 2019, at 8:00 PM, Peng Yu wrote: > > > I'd like to mimic the V sort ord

How to implement the V comparsion used by sort in python?

2019-10-25 Thread Peng Yu
Hi, I'd like to mimic the V sort order in python. Is there any easy to use comparison available in python? The following implementation is simple but it is not exactly the same as the sort order of V used in sort. Thanks. https://blog.codinghorror.com/sorting-for-humans-natural-sort-order/ -- R

Can natural sort support be added?

2019-10-08 Thread Peng Yu
Hi, Since natural sort is provided in a few languages (as mentioned in the Wikipedia page). Can it be supported by `sort` besides just version-sort? https://en.wikipedia.org/wiki/Natural_sort_order -- Regards, Peng

Re: Is natural sort supported?

2019-10-08 Thread Peng Yu
> At the risk of arguing over semantics, > I'll say again: there is no "one correct" natural order standard, > and therefore it is not "plain and simple" because there is no just > "one" such order. I don't think there is no commonly accepted "natural sort". For example, I found another one that u

Re: Is natural sort supported?

2019-10-08 Thread Peng Yu
Some part of the manual is also poorly written. "1.1.2 Origin of version sort and differences from natural sort" After reading the above section, I am still not clear what is the difference. It is better to show some examples to illustrate the difference. On 10/8/19, Peng Yu wrote: &

Re: Is natural sort supported?

2019-10-08 Thread Peng Yu
code. https://blog.codinghorror.com/sorting-for-humans-natural-sort-order/ So my question is whether natural order as in the above URL is supported? On 10/8/19, Assaf Gordon wrote: > Hello, > > On 2019-10-08 12:36 a.m., Peng Yu wrote: >> The following example shows that version sort

Is natural sort supported?

2019-10-07 Thread Peng Yu
Hi, The following example shows that version sort is not natural sort. Is natural sort supported in by `sort`? $ printf '%s\n' G . | LC_ALL=C sort -k 1,1V . G $ printf '%s\n' 1G 1. | LC_ALL=C sort -k 1,1V 1. 1G $ printf '%s\n' 1G13 1.02 | LC_ALL=C sort -k 1,1V # The result order should have been

Re: How to sort unicode properly?

2019-09-25 Thread Peng Yu
If python can have pyuca that works across platform, why such thing can not have at C level? On Wed, Sep 25, 2019 at 12:24 PM Eric Blake wrote: > On 9/25/19 10:56 AM, Peng Yu wrote: > > I want to make my `sort` to be machine-independent and always use the > > correct Unicode

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

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 acc

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 2.5632e

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

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

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

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

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

2019-06-30 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

Re: How to sort and count efficiently?

2019-06-30 Thread Peng Yu
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 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 s

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 20

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'

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: > > >

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

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

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 ~/Downlo

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? T

Re: performance bug of `wc -m`

2018-05-13 Thread Peng Yu
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 > gnu coreutils' wc and not the maco

Re: performance bug of `wc -m`

2018-05-13 Thread Peng Yu
lo, > > 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 other issues a

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 += len

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

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 numb

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

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 0

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. h

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? $ time

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

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

How to sort alphabetically?

2017-08-13 Thread Peng Yu
Hi, "B" is listed before "a". Is there a way to sort alphabetically (as in an English dictionary)? (I think LC_* might need to be used, but I am not sure what value it should be.) Thanks. $ printf '%s\n' a B c | sort B a c -- Regards, Peng

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

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 "$?" readlin

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

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? -- Regards

How to ignore an empty file with paste

2016-03-04 Thread Peng Yu
Hi, This example shows that an empty file will be used to create an empty column. But in some cases, it makes more sense to just ignore such a column. Is there a way to instruct paste to ignore an empty file? $ > empty_file $ paste empty_file <(seq 3) 1 2 3 -- Regards, Peng

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

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 -

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

ls does not show broken like in red (coreutils installed from MacPorts)

2015-04-24 Thread Peng Yu
Hi, `ls` does not show broken links in red. Does anybody know what is wrong? I show the things with ls below. /tmp$ echo $LS_COLORS /tmp$ dircolors LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:

Re: Does sort handle -t / correctly

2015-04-17 Thread Peng Yu
On Fri, Apr 17, 2015 at 2:05 PM, Peng Yu wrote: > On Fri, Apr 17, 2015 at 12:31 PM, Eric Blake wrote: >> On 04/17/2015 11:03 AM, Peng Yu wrote: >>> On Fri, Apr 17, 2015 at 11:26 AM, Eric Blake wrote: >>>> On 04/17/2015 10:10 AM, Peng Yu wrote: >>>>>

Re: Does sort handle -t / correctly

2015-04-17 Thread Peng Yu
On Fri, Apr 17, 2015 at 12:31 PM, Eric Blake wrote: > On 04/17/2015 11:03 AM, Peng Yu wrote: >> On Fri, Apr 17, 2015 at 11:26 AM, Eric Blake 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

Re: Does sort handle -t / correctly

2015-04-17 Thread Peng Yu
On Fri, Apr 17, 2015 at 11:26 AM, Eric Blake 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

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

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? -- Regar

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 div

-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

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 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/question

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

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 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

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

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.

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

  1   2   >