I try to handle very large numbers with a bash script. I run ssh command in a remote server and store the output in a local variable. But this output contains a return carriage at the end. So I try to remove it by tr But I can't figure out the right notation with printf. So my problem is:
If I use tr -dc '[:digit:]' with this printf output, it will remove all non character not only return carriage at the end.
So for first notation it will give me a number like 2809850000000000 and for second 28098509 and both incorrect. I need a display like 2809850000 so tr could only remove return carriage. So which parameter of printf would produce this notation? (w/o exponential nor decimal notation)
-v var=val
--assign var=val
Assign the value val to the variable var, before execution of the program begins. Such variable values are available to the
BEGIN block of an AWK program.
Please be careful - that trick with awk works because when converting a field to a numerical value, awk will start at the beginning of the field and scan until an unconvertible char is encountered - which is "\" "r" in post#2. Yes - it's not <CR> but two normal chars.
The second assignment really has a <CR> char in it, making echo overprint the first chars.
To remove the <CR>, you can try this bashism (pattern substitution expansion):