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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -