Is this a useless use of "cat"?

I cannot figure out how to make the following work without using cat. I am not worried about the forked process or whatever, it just doesn't bother me:

$ printf "<format specification string>" $(cat source-file.txt)


Is there a better way?


source to share

2 answers

Yes. You can accomplish the same thing without creating a new process for cat

, with:

$ printf "<format specification string>" $(<source-file.txt)




Even if it is a useless use of cat, I would still use cat

to output the contents of the file instead <

in this case, because it precludes the possibility of overwriting the input file by overriding the typo ( >

) symbol



All Articles