LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Round up to 2 decimal place with the character at last (https://www.linuxquestions.org/questions/linux-newbie-8/round-up-to-2-decimal-place-with-the-character-at-last-4175480753/)

danielbmartin 10-17-2013 08:29 PM

Quote:

Originally Posted by grail (Post 5047518)
Code:

awk -F "" '{f="%"(/\./?".2":".0")"f%s\n";printf f,$0,$NF}' file

grail, I hammered your clever solution to even fewer keystrokes...
Code:

awk -F "" '{printf "%."(/\./*2)"f%s\n",$0,$NF}' file
Daniel B. Martin

grail 10-18-2013 02:19 AM

Quote:

Originally Posted by danielbmartin (Post 5047795)
grail, I hammered your clever solution to even fewer keystrokes...
Code:

awk -F "" '{printf "%."(/\./*2)"f%s\n",$0,$NF}' file
Daniel B. Martin

Nice :)


All times are GMT -5. The time now is 10:55 AM.