shell - Add preceding zeros to all lines in a file -
i have simple text file containing random number on every line. wish add preceding zeros numbers less in digits. there way on command line (unix)
input file:
235 25 1 963258 45 1356924
output file:
0000235 0000025 0000001 0963258 0000045 1356924
using awk
- printf
:
$ cat testfile 235 25 1 963258 45 1356924 $ awk '{printf("%07d\n", $1)}' testfile # %07d pad 0s. 0000235 0000025 0000001 0963258 0000045 1356924
Comments
Post a Comment