Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I append the same byte to a file a specified number of times?

I have the following code:

yes "$(echo -e "\xff")" | head -n 10 > SomeFile.bin

Which writes 10 times 0xFF and 0x0A (newline) to SomeFile.bin. But my objective is to fill the file with FF.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is there a way to print only consecutive 0xFF values instead? Without adding a newline every time?

>Solution :

Here is one way:

printf '\xFF%.s' {1..10} >SomeFile.bin
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading