File input/output: Difference between revisions

Content added Content deleted
(mv jq before julia)
(jq moved)
Line 1,344: Line 1,344:
var fs = require('fs');
var fs = require('fs');
require('util').pump(fs.createReadStream('input.txt', {flags:'r'}), fs.createWriteStream('output.txt', {flags:'w+'}));
require('util').pump(fs.createReadStream('input.txt', {flags:'r'}), fs.createWriteStream('output.txt', {flags:'w+'}));
</lang>

=={{header|jq}}==
If the input file consists of ordinary lines of text, then the lines can be copied verbatim, one by one, as follows:
<lang jq>jq -M --raw-input --raw-output '. as $line | $line' input.txt > output.txt
</lang>

If the input consists of JSON, and if we wish to "pretty print" it, then the following will suffice:<lang jq>
jq -M '. as $line | $line' input.txt > output.txt
</lang>
</lang>