File input/output: Difference between revisions

Content added Content deleted
m (→‎[[Java]]: Fixed up layout slightly.)
(→‎[[UNIX Shell]]: Fixed up formatting)
Line 424: Line 424:


#!/bin/sh
#!/bin/sh
while read a; do
while read a; do
echo "$a"
echo "$a"
done <input.txt >output.txt
done <input.txt >output.txt

Another way, using the 'cat' program


#!/bin/sh
#!/bin/sh
# another way, using the 'cat' program
cat input.txt >output.txt
cat input.txt >output.txt


# yet another way, using the 'cp' utility
Yet another way, using the 'cp' utility
#!/bin/sh
cp input.txt output.txt
cp input.txt output.txt