Y
Hacker News
new
|
ask
|
show
|
jobs
by
darrenf
2685 days ago
Why even use awk rather than the shell's (well, bash's) builtin printf?
$ printf '%d\n' "0005" 5
2 comments
jfk13
2684 days ago
That might not always do what a naïve user expects:
$ printf '%d\n' "0025" 21
link
inp
2685 days ago
You can apply the awk command on a pipe, and so it is applies on each line of the file/stream.
link
darrenf
2684 days ago
Right - though that's solvable with xargs:
$ echo "0005" | xargs printf '%d\n' 5
That said, my suggestion doesn't work anyway since the leading 0 marks it as octal, d'oh (as mentioned elsewhere in the thread).
link