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 put 0 before everyline in a txt file?

I had to generate a txt file for a given range of numbers. As usual I had to use seq range_start range_end > text_file.txt to put it in a txt file. I gave the seq range where the starting point was 01700 and the ending point was 01800. I know it’s useless to have 0 before the number but in my case it was important. The file generated had lines like 1700, 1701 … 1800. But there was no 0 before the numbers as I put in the command. So, based on the situation how am I supposed to put 0 before every line in the txt file? Or is there any way to generate the txt with 0 in it before every line?

>Solution :

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

Try seq -w to keep consistent output width.

seq -w 01700 01800 will output 01700, 01701 etc.

As always, man seq should be your starting point when wondering about seq. Unix manpages are there for a reason, and very often solve such questions up front.

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