You're just missing a comma after the format string, e.g.
awk -F'[:_\t]' '{ printf "%s\t%4.0f\t%4.0f\t%s\n", "chr"
2-1,
1":"$2"_"$3"_"$4 }' file
# ^
# |
# this one
Answer from Freddy on Stack ExchangeYou're just missing a comma after the format string, e.g.
awk -F'[:_\t]' '{ printf "%s\t%4.0f\t%4.0f\t%s\n", "chr"
2-1,
1":"$2"_"$3"_"$4 }' file
# ^
# |
# this one
I can't reproduce your problem at all but assuming it does exist this may help you:
$ cat tst.awk
BEGIN { OFS="\t"; OFMT="%d" }
{
split($1,f,/[:_]/)
print "chr"f[1], f[2]-1, f[2], $1
}
$ awk -f tst.awk file
chr10 100000624 100000625 10:100000625_A_G
chr10 100000644 100000645 10:100000645_A_C
chr10 100002463 100002464 10:100002464_C_T
chr10 100003241 100003242 10:100003242_G_T
chr10 100003303 100003304 10:100003304_A_G
chr10 10000337 10000338 10:10000338_C_T
chr10 100003515 100003516 10:100003516_A_G
chr10 100003784 100003785 10:100003785_C_T
chr10 100004359 100004360 10:100004360_A_G
chr10 100004440 100004441 10:100004441_C_G
If %d format doesn't do what you need but %4.0f does, then just change OFMT="%d" to OFMT="%4.0f".
That stuff you mention about the first column being pushed down and the 4th column being truncated probably means you have DOS line endings in your input, see https://stackoverflow.com/questions/45772525/why-does-my-tool-output-overwrite-itself-and-how-do-i-fix-it.
The 5th comma-separated field from the uptime output is non-existant (on my system at least), which is why you keep getting zero. The 5-minute uptime is the second-to-last field, so this works:
uptime | awk '{printf "%.0f\n",$(NF-1)}'
Simplest version (use built-in awk printf - kudos Dennis Williamson):
uptime |awk -F, '{printf "%0.f\n",$5}'
Original answer: Run it through xargs instead.
uptime |awk -F, '{print $5}' |xargs printf "%0.f\n"