ShellJS - にほんご。

ShellString.prototype.toEnd()

更新日: 2018-09-11

ShellString.prototype.toEnd(file)

指定方法

cat('input.txt').toEnd('output.txt');

Unixのリダイレクト演算子>>に似ていますが、ShellStrings(cat()grep()等から返されたもの)と一緒に使用します。


使用例

'shell1.txt'の先頭3行を読み込み、'result.txt'に追記します。

JavaScript
var sh = require('shelljs');
sh.head({'-n': 3}, 'shell1.txt').toEnd('result.txt');
sh.echo(sh.cat('result.txt'));
sh.echo('----------');
sh.head({'-n': 3}, 'shell1.txt').toEnd('result.txt');
sh.echo(sh.cat('result.txt'));
txt
aaaaa
bbbbb
ccccc
ddddd
eeeee
結果
$ node sample.js
aaaaa
bbbbb
ccccc

----------
aaaaa
bbbbb
ccccc
aaaaa
bbbbb
ccccc


© 2012 Artur Adib Released under the BSD License. See LICENSE file for details.

このコンテンツはArtur Adib(arturadib)によるShellJSドキュメントを翻訳/改変したものです。