Jump to content

File input/output: Difference between revisions

jq moved
(mv jq before julia)
(jq moved)
Line 1,344:
var fs = require('fs');
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>
 
2,502

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.