blog :: unforswearing.com
I have been trying to find ways to avoid useless
use of cat but could never come up with a method of reading a file
that did not involve creating an entire for
or
while
loop. This problem crossed my mind yesterday and,
after a quick google search, I found
a neat way to avoid this in a single small command:
# contents of 'hi.txt'
cat hi.txt
hi
hello
ok
# reading hi.txt without 'cat'
echo $(<hi.txt)
hi hello ok
Unfortunately, the command does not preserve new lines but for those times when you only need to read from a single line file, this does the trick.
back to blog
github
:: audio / sound :: home