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?

+3


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)

      

+7


source


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



0


source







All Articles