GNU coreutils – matoken's blog https://matoken.org/blog Is there no plan B? Thu, 05 Feb 2026 21:07:09 +0000 ja hourly 1 https://wordpress.org/?v=7.0 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg GNU coreutils – matoken's blog https://matoken.org/blog 32 32 GNU coreutils 9.10でpasteのデリミタにマルチバイト文字が利用可能に https://matoken.org/blog/2026/02/06/gnu-coreutils-9-10-paste/ https://matoken.org/blog/2026/02/06/gnu-coreutils-9-10-paste/#respond Thu, 05 Feb 2026 21:07:07 +0000 https://matoken.org/blog/?p=5219

GNU coreutils 9.10 がリリースされました.

paste でマルチバイト文字を認識するようになったそうです.まだ対応していなかったんだとちょっと試してみました.

  • paste(1) is now multi-byte character aware

まずは適当なファイルを用意します.

$ echo '1
2
3' > num
$ echo 'い
ろ
は' > data

GNU coreutils 9.7 のpaste で試すと日本語のデータもうまく動いていそうです.

$ paste --version | head -1
paste (GNU coreutils) 9.7
$ paste num data
1       い
2       ろ
3       は

NEWS の下の方を見ると少し詳しく書いてありました.

'paste' now supports multi-byte --delimiters characters.

デリミタにマルチバイト文字が使えるようになったようです.

ということで再度,今度はデミリタを指定します.

GNU coreutils 9.7 のpaste でデリミタに , を指定
$ paste num data -d,
1,い
2,ろ
3,は
GNU coreutils 9.7 のpaste でデリミタに を指定
$ paste num data -d=
1��
2��
3��

たしかにマルチバイト文字を使うとおかしくなります.

GNU coreutils 9.10 を用意
$ wget https://ftp.gnu.org/gnu/coreutils/coreutils-9.10.tar.xz \
	https://ftp.gnu.org/gnu/coreutils/coreutils-9.10.tar.xz.sig
$ echo 'SHA256 (coreutils-9.10.tar.xz) = FlNamt8LEANzZOLWEqrT2fTso6NElJztdNEvr0vVHSU=' | cksum -a sha256 --check
coreutils-9.10.tar.xz: OK
$ gpg --verify coreutils-9.10.tar.xz.sig
gpg: assuming signed data in 'coreutils-9.10.tar.xz'
gpg: Signature made Wed Feb  4 21:46:29 2026 JST
gpg:                using RSA key 6C37DC12121A5006BC1DB804DF6FD971306037D9
gpg: Good signature from "P draig Brady <P@draigBrady.com>" [unknown]
gpg:                 aka "P draig Brady <pixelbeat@gnu.org>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 6C37 DC12 121A 5006 BC1D  B804 DF6F D971 3060 37D9
$ tar xvf coreutils-9.10.tar.xz
$ cd coreutils-9.10
$ sudo apt build-dep coreutils
$ ./configure
$ make
$ src/paste --version | head -1
paste (GNU coreutils) 9.10
GNU coreutils 9.10 のpaste でデリミタにマルチバイト文字を指定
$ ./src/paste num data -d=
1=い
2=ろ
3=は
$ ./src/paste num data -d🐈
1🐈い
2🐈ろ
3🐈は

ということでGNU coreutils 9.10 のpaste でデリミタにマルチバイト文字が使えるようになっているのが確認できました.
使い道はあまり浮かびませんが…….

環境
$ dpkg-query -W coreutils
coreutils       9.7-3
$ src/paste --version
paste (GNU coreutils) 9.10
Copyright (C) 2026 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David M. Ihnat and David MacKenzie.
$ lsb_release -dr
Description:    Debian GNU/Linux forky/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2026/02/06/gnu-coreutils-9-10-paste/feed/ 0
GNU coreutilsのcatで改行コードなどを確認する https://matoken.org/blog/2021/02/05/display-line-feed-code-etc-with-cat-of-gnu-coreutils/ https://matoken.org/blog/2021/02/05/display-line-feed-code-etc-with-cat-of-gnu-coreutils/#respond Thu, 04 Feb 2021 15:55:53 +0000 http://matoken.org/blog/?p=2963

最近知りました.

LC_MESSAGES=ja_JP.UTF-8のcat(1)
$ LC_MESSAGES=ja_JP.UTF-8 man cat | grep '\-A' -A25
       -A, --show-all           -vET と同じ

       -b, --number-nonblank
              空行以外に行番号を付ける。-n より優先される

       -e                       -vE と同じ

       -E, --show-ends
              行の最後に $ を付ける

       -n, --number
              全ての行に行番号を付ける

       -s, --squeeze-blank
              連続した空行の出力を行わない

       -t                       -vT と同じ

       -T, --show-tabs
              TAB 文字を ^I で表示

       -u     (無視)

       -v, --show-nonprinting
              ^ や M- 表記を使用する (LFD と TAB は除く)
LC_MESSAGES=Cのcat(1)
$ LC_MESSAGES=C man cat | grep '\-A' -A26
       -A, --show-all
              equivalent to -vET

       -b, --number-nonblank
              number nonempty output lines, overrides -n

       -e     equivalent to -vE

       -E, --show-ends
              display $ at end of each line

       -n, --number
              number all output lines

       -s, --squeeze-blank
              suppress repeated empty output lines

       -t     equivalent to -vT

       -T, --show-tabs
              display TAB characters as ^I

       -u     (ignored)

       -v, --show-nonprinting
              use ^ and M- notation, except for LFD and TAB
テストファイル作成
$ echo 'hoge
>       fuga
> ' | unix2dos > /tmp/test
odで中身確認
$ od -xc /tmp/test
0000000    6f68    6567    0a0d    6609    6775    0d61    0d0a    000a
          h   o   g   e  \r  \n  \t   f   u   g   a  \r  \n  \r  \n
0000017
普通にcat
$ cat /tmp/test
hoge
	fuga
-T でTABを ^I として表示
$ cat -T /tmp/test
hoge
^Ifuga
-v で\nやTABを除く制御コードを表示ここでは\rが^Mとして表示されている
$ cat -v /tmp/test
hoge^M
	fuga^M
^M
-t-vT と同じ
$ cat -t /tmp/test
hoge^M
^Ifuga^M
^M
-E で行末に$を表示.\rがあると頭に付いてしまうよう
$ cat -E /tmp/test
$oge
$	fuga
$
Note
追記 2020-02-10)
Debianでreportbugしたらpatchが :)
Debian 11 BullseyeやUbuntu 21.04に入るかな?
https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=982208;filename=cat—​show-ends.diff;msg=10
-A-vET と同じ
$ cat -A /tmp/test
hoge^M$
^Ifuga^M$
^M$
-n で行番号を表示
$ cat -n /tmp/test
     1	hoge
     2		fuga
     3
-An で行番号と記号
$ cat -An /tmp/test
     1	hoge^M$
     2	^Ifuga^M$
     3	^M$

vimでは :set list, :set number でだいたい同じ感じでしょうか.

vim
  1 hoge$
  2 ^Ifuga$
  3 $

vim

環境
$ cat --version
cat (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjorn Granlund and Richard M. Stallman.
$ dpkg-query -W coreutils
coreutils	8.32-4+b1
$ lsb_release -dr
Description:	Debian GNU/Linux bullseye/sid
Release:	unstable
$ uname -m
x86_64
]]>
https://matoken.org/blog/2021/02/05/display-line-feed-code-etc-with-cat-of-gnu-coreutils/feed/ 0
GNU coreutils の dd に プログレスオプションがあった https://matoken.org/blog/2018/08/14/gnu-coreutils-dd-had-a-progress-option/ https://matoken.org/blog/2018/08/14/gnu-coreutils-dd-had-a-progress-option/#respond Mon, 13 Aug 2018 21:27:34 +0000 http://matoken.org/blog/?p=2027

dd の進捗は SIGUSR1 を投げると覚えていたのですが,man を眺めていると status=progress というオプションがあるのに気づきました.

manより
status=LEVEL
       The LEVEL of information to print to stderr; 'none' suppresses
       everything but error messages, 'noxfer' suppresses  the  final
       transfer  statistics,  'progress' shows periodic transfer sta‐
       tistics

2015-07-03 の GNU coreutils 8.24 で入ったようです.

dd accepts a new status=progress level to print data transfer statistics
on stderr approximately every second.

これまでも独自パッチでddにプログレスを出すようにするものなどはありましたがGNU ddに導入されていたんですね.気づきませんでした.

てことで試してみます.まずは従来の方法から.

dd開始
$ dd if=/dev/urandom of=/dev/null count=99999 &
[1] 19386
killコマンドで USER1 シグナルを投げる
$ kill -USR1 19522
2294+0 レコード入力
2293+0 レコード出力
2404384768 bytes (2.4 GB, 2.2 GiB) copied, 11.0258 s, 218 MB/s
killallコマンドでpidではなくプロセス名を指定
$ killall -USR1 dd
15648+1 レコード入力
15647+1 レコード出力
16407664896 bytes (16 GB, 15 GiB) copied, 76.1063 s, 216 MB/s

※pkillを使うと部分一致になるので意図しないプロセスにシグナルを送ってしまうことがあるので注意

$ pgrep dd
2
70
3937
$ ps 2 70 3937
  PID TTY      STAT   TIME COMMAND
    2 ?        S      0:00 [kthreadd]
   70 ?        I<     0:00 [ipv6_addrconf]
 3937 pts/9    R      0:13 dd if=/dev/urandom of=/dev/null bs=1M count=99999
watchコマンドで定期的に実行
$ watch killall -USR1 dd
98448+3 レコード入力
98447+3 レコード出力
103231407040 bytes (103 GB, 96 GiB) copied, 487.072 s, 212 MB/s
 :
ddコマンド実行時にpvコマンドを挟む
$ cat /dev/urandom | pv | dd of=/dev/null bs=1M count=99999
1.06GiB 0:00:06 [ 182MiB/s] [     <=>                                        ]
pvコマンドでファイル出力
$ pv /dev/urandom | dd of=/dev/null bs=1M count=99999
 502MiB 0:00:03 [ 170MiB/s] [  <=>                                           ]
ddの status=progress オプションを利用
$ dd if=/dev/urandom of=/dev/null bs=1M count=99999 status=progress
1910505472 bytes (1.9 GB, 1.8 GiB) copied, 9 s, 212 MB/s

流石に純正だけあっていい感じですね.問題はいざ使うときに思い出せるかという…….pvが覚えやすくて便利なんですよね.

そもそもdd使わずGNU ddrescue を使う?まあ大抵の用途ではそっちのほうが良いかもです.

試した環境
$ dd --version
dd (coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
ライセンス GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

作者 Paul Rubin、 David MacKenzie、および Stuart Kemp。
$ dpkg-query -W coreutils
coreutils       8.28-1
pv      1.6.6-1
$ lsb_release -d
Description:    Debian GNU/Linux unstable (sid)
$ uname -m
x86_64

]]>
https://matoken.org/blog/2018/08/14/gnu-coreutils-dd-had-a-progress-option/feed/ 0