Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this a useless use of `cat`?

Tags:

bash

I can't figure out how to make the following work without using cat. I'm not worried about the forked process or anything, it just unsettles me:

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

Is there a better way?

like image 556
Jamie Avatar asked Nov 26 '25 10:11

Jamie


1 Answers

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

$ printf "<format specification string>" $(<source-file.txt)
like image 56
Adam Liss Avatar answered Nov 29 '25 10:11

Adam Liss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!