サイト内検索:
itouch : ファイルの初期化を行う
使い方とオプション
itouch [-<n>] "<string>" <file1> <file2>...
itouch [-<n>] -f <file> <file1> <file2>...
-n
指定ファイルが存在しない、あるいは0バイトならば、<string>あるいは <file> でファイルの中身を初期化します。-<n> で数字を指定すると<n>行分の<string>あるいは<n>回分の<file>で初期化します。初期化するファイルは複数指定できます。ファイルが存在して0バイトで無い場合は何もしません。指定ファイルが “-” のときは、標準入力を期待し、結果を標準出力に出力します。
$ cat file
cat: file: No such file or directory <-- ファイルが存在しないか0バイトの場合
$ itouch '000 000 0' file
$ cat file
000 000 0 <-- 指定文字列で初期化される
$ itouch 'abc abc 0' file <-- ファイルが存在して0バイトでない場合
$ cat file
000 000 0
$ : > file
$ itouch -3 '000 000 0' file <-- 3行初期化
$ cat file
000 000 0
000 000 0
000 000 0
$ : > file
$ itouch 'a\nb\nc' file <-- '\n' は改行に置換される
$ cat file
a
b
c
$ cat file1
$ cat file1 | itouch '000 0' - > result <-- 標準入力から0バイト
$ cat result ファイルを読む
000 0
$ cat file2
ABC D
$ cat file2 | itouch '000 0' - > result <-- 標準入力から中身のある
$ cat result ファイルを読む
ABC D
$ : > file
$ echo abc > init <-- 初期化用のファイルを準備する
$ itouch -f init file <-- 初期化ファイル init で file を初期化する
$ cat file
abc
Version : Sat Jun 24 22:47:40 JST 2017
© 2021 Universal Shell Programming Laboratory site