how to introduce multiplication in shell scripting [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
This question already has an answer here:
How to do integer & float calculations, in bash or other languages/frameworks?
16 answers
My command is:
tac some_directory/*.pre | grep -im1 "vdr" | cut -c129-140
Output is:
1.710577E-03
I want the output to be:
1.71
How can I achieve this in the shell command?
shell-script awk
marked as duplicate by Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jul 6 at 5:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
1
down vote
favorite
This question already has an answer here:
How to do integer & float calculations, in bash or other languages/frameworks?
16 answers
My command is:
tac some_directory/*.pre | grep -im1 "vdr" | cut -c129-140
Output is:
1.710577E-03
I want the output to be:
1.71
How can I achieve this in the shell command?
shell-script awk
marked as duplicate by Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jul 6 at 5:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
post a testable input fragment
â RomanPerekhrest
Jun 27 at 11:59
USetac some_directory/*.pre | grep -im1 "vdr" | cut -c129-132
â Arushix
Jun 27 at 12:05
Which shell are you using?
â andcoz
Jun 27 at 12:31
its exponential of-3
output will be 0.00171
â SivaPrasath
Jun 27 at 12:50
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
This question already has an answer here:
How to do integer & float calculations, in bash or other languages/frameworks?
16 answers
My command is:
tac some_directory/*.pre | grep -im1 "vdr" | cut -c129-140
Output is:
1.710577E-03
I want the output to be:
1.71
How can I achieve this in the shell command?
shell-script awk
This question already has an answer here:
How to do integer & float calculations, in bash or other languages/frameworks?
16 answers
My command is:
tac some_directory/*.pre | grep -im1 "vdr" | cut -c129-140
Output is:
1.710577E-03
I want the output to be:
1.71
How can I achieve this in the shell command?
This question already has an answer here:
How to do integer & float calculations, in bash or other languages/frameworks?
16 answers
shell-script awk
edited Jul 9 at 12:32
schily
8,57421435
8,57421435
asked Jun 27 at 11:56
Nayak
306
306
marked as duplicate by Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jul 6 at 5:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jul 6 at 5:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
post a testable input fragment
â RomanPerekhrest
Jun 27 at 11:59
USetac some_directory/*.pre | grep -im1 "vdr" | cut -c129-132
â Arushix
Jun 27 at 12:05
Which shell are you using?
â andcoz
Jun 27 at 12:31
its exponential of-3
output will be 0.00171
â SivaPrasath
Jun 27 at 12:50
add a comment |Â
1
post a testable input fragment
â RomanPerekhrest
Jun 27 at 11:59
USetac some_directory/*.pre | grep -im1 "vdr" | cut -c129-132
â Arushix
Jun 27 at 12:05
Which shell are you using?
â andcoz
Jun 27 at 12:31
its exponential of-3
output will be 0.00171
â SivaPrasath
Jun 27 at 12:50
1
1
post a testable input fragment
â RomanPerekhrest
Jun 27 at 11:59
post a testable input fragment
â RomanPerekhrest
Jun 27 at 11:59
USe
tac some_directory/*.pre | grep -im1 "vdr" | cut -c129-132
â Arushix
Jun 27 at 12:05
USe
tac some_directory/*.pre | grep -im1 "vdr" | cut -c129-132
â Arushix
Jun 27 at 12:05
Which shell are you using?
â andcoz
Jun 27 at 12:31
Which shell are you using?
â andcoz
Jun 27 at 12:31
its exponential of
-3
output will be 0.00171â SivaPrasath
Jun 27 at 12:50
its exponential of
-3
output will be 0.00171â SivaPrasath
Jun 27 at 12:50
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
10
down vote
accepted
Using awk:
As per your expected output:
echo 1.710577E-03 | awk 'printf "%.2fn",a=$1*1000; a'
1.71
Actual roundoff:
echo 1.710577E-03 | awk 'printf "%.5fn",$1'
0.00171
%.5
print up to 5 decimals.f
float converter.
Thanks.....will you please explain the second block after pipe.!!
â Nayak
Jul 6 at 5:28
is it possible to avoid 'a' variable in 'awk' block ? I am trying to couple this command with another programm and 'a' is a kind of conficting. the entire command is : rea plu echo set var num 0:ex1tac *.pre | grep -i -m1 "vdr" | cut -c129-140 | echo
awk 'printf "%.2fn",a=$1*1000; a'``.... 'rea plu echo set var num 0:ex1' is plugin from another programm, and rest is shell.
â Nayak
Jul 9 at 9:30
I have already tried...but unfortuntely in combination with plugin does not work.
â Nayak
Jul 9 at 9:50
can you share part of a plugin with error?
â SivaPrasath
Jul 9 at 9:52
awk: cmd. line:1: {printf ...then in next line awk: cmd. line:1: ^ unexpected newline or end of string
â Nayak
Jul 9 at 12:13
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
10
down vote
accepted
Using awk:
As per your expected output:
echo 1.710577E-03 | awk 'printf "%.2fn",a=$1*1000; a'
1.71
Actual roundoff:
echo 1.710577E-03 | awk 'printf "%.5fn",$1'
0.00171
%.5
print up to 5 decimals.f
float converter.
Thanks.....will you please explain the second block after pipe.!!
â Nayak
Jul 6 at 5:28
is it possible to avoid 'a' variable in 'awk' block ? I am trying to couple this command with another programm and 'a' is a kind of conficting. the entire command is : rea plu echo set var num 0:ex1tac *.pre | grep -i -m1 "vdr" | cut -c129-140 | echo
awk 'printf "%.2fn",a=$1*1000; a'``.... 'rea plu echo set var num 0:ex1' is plugin from another programm, and rest is shell.
â Nayak
Jul 9 at 9:30
I have already tried...but unfortuntely in combination with plugin does not work.
â Nayak
Jul 9 at 9:50
can you share part of a plugin with error?
â SivaPrasath
Jul 9 at 9:52
awk: cmd. line:1: {printf ...then in next line awk: cmd. line:1: ^ unexpected newline or end of string
â Nayak
Jul 9 at 12:13
 |Â
show 1 more comment
up vote
10
down vote
accepted
Using awk:
As per your expected output:
echo 1.710577E-03 | awk 'printf "%.2fn",a=$1*1000; a'
1.71
Actual roundoff:
echo 1.710577E-03 | awk 'printf "%.5fn",$1'
0.00171
%.5
print up to 5 decimals.f
float converter.
Thanks.....will you please explain the second block after pipe.!!
â Nayak
Jul 6 at 5:28
is it possible to avoid 'a' variable in 'awk' block ? I am trying to couple this command with another programm and 'a' is a kind of conficting. the entire command is : rea plu echo set var num 0:ex1tac *.pre | grep -i -m1 "vdr" | cut -c129-140 | echo
awk 'printf "%.2fn",a=$1*1000; a'``.... 'rea plu echo set var num 0:ex1' is plugin from another programm, and rest is shell.
â Nayak
Jul 9 at 9:30
I have already tried...but unfortuntely in combination with plugin does not work.
â Nayak
Jul 9 at 9:50
can you share part of a plugin with error?
â SivaPrasath
Jul 9 at 9:52
awk: cmd. line:1: {printf ...then in next line awk: cmd. line:1: ^ unexpected newline or end of string
â Nayak
Jul 9 at 12:13
 |Â
show 1 more comment
up vote
10
down vote
accepted
up vote
10
down vote
accepted
Using awk:
As per your expected output:
echo 1.710577E-03 | awk 'printf "%.2fn",a=$1*1000; a'
1.71
Actual roundoff:
echo 1.710577E-03 | awk 'printf "%.5fn",$1'
0.00171
%.5
print up to 5 decimals.f
float converter.
Using awk:
As per your expected output:
echo 1.710577E-03 | awk 'printf "%.2fn",a=$1*1000; a'
1.71
Actual roundoff:
echo 1.710577E-03 | awk 'printf "%.5fn",$1'
0.00171
%.5
print up to 5 decimals.f
float converter.
edited Jul 9 at 9:34
answered Jun 27 at 12:54
SivaPrasath
3,88611737
3,88611737
Thanks.....will you please explain the second block after pipe.!!
â Nayak
Jul 6 at 5:28
is it possible to avoid 'a' variable in 'awk' block ? I am trying to couple this command with another programm and 'a' is a kind of conficting. the entire command is : rea plu echo set var num 0:ex1tac *.pre | grep -i -m1 "vdr" | cut -c129-140 | echo
awk 'printf "%.2fn",a=$1*1000; a'``.... 'rea plu echo set var num 0:ex1' is plugin from another programm, and rest is shell.
â Nayak
Jul 9 at 9:30
I have already tried...but unfortuntely in combination with plugin does not work.
â Nayak
Jul 9 at 9:50
can you share part of a plugin with error?
â SivaPrasath
Jul 9 at 9:52
awk: cmd. line:1: {printf ...then in next line awk: cmd. line:1: ^ unexpected newline or end of string
â Nayak
Jul 9 at 12:13
 |Â
show 1 more comment
Thanks.....will you please explain the second block after pipe.!!
â Nayak
Jul 6 at 5:28
is it possible to avoid 'a' variable in 'awk' block ? I am trying to couple this command with another programm and 'a' is a kind of conficting. the entire command is : rea plu echo set var num 0:ex1tac *.pre | grep -i -m1 "vdr" | cut -c129-140 | echo
awk 'printf "%.2fn",a=$1*1000; a'``.... 'rea plu echo set var num 0:ex1' is plugin from another programm, and rest is shell.
â Nayak
Jul 9 at 9:30
I have already tried...but unfortuntely in combination with plugin does not work.
â Nayak
Jul 9 at 9:50
can you share part of a plugin with error?
â SivaPrasath
Jul 9 at 9:52
awk: cmd. line:1: {printf ...then in next line awk: cmd. line:1: ^ unexpected newline or end of string
â Nayak
Jul 9 at 12:13
Thanks.....will you please explain the second block after pipe.!!
â Nayak
Jul 6 at 5:28
Thanks.....will you please explain the second block after pipe.!!
â Nayak
Jul 6 at 5:28
is it possible to avoid 'a' variable in 'awk' block ? I am trying to couple this command with another programm and 'a' is a kind of conficting. the entire command is : rea plu echo set var num 0:ex1
tac *.pre | grep -i -m1 "vdr" | cut -c129-140 | echo
awk 'printf "%.2fn",a=$1*1000; a'``.... 'rea plu echo set var num 0:ex1' is plugin from another programm, and rest is shell.â Nayak
Jul 9 at 9:30
is it possible to avoid 'a' variable in 'awk' block ? I am trying to couple this command with another programm and 'a' is a kind of conficting. the entire command is : rea plu echo set var num 0:ex1
tac *.pre | grep -i -m1 "vdr" | cut -c129-140 | echo
awk 'printf "%.2fn",a=$1*1000; a'``.... 'rea plu echo set var num 0:ex1' is plugin from another programm, and rest is shell.â Nayak
Jul 9 at 9:30
I have already tried...but unfortuntely in combination with plugin does not work.
â Nayak
Jul 9 at 9:50
I have already tried...but unfortuntely in combination with plugin does not work.
â Nayak
Jul 9 at 9:50
can you share part of a plugin with error?
â SivaPrasath
Jul 9 at 9:52
can you share part of a plugin with error?
â SivaPrasath
Jul 9 at 9:52
awk: cmd. line:1: {printf ...then in next line awk: cmd. line:1: ^ unexpected newline or end of string
â Nayak
Jul 9 at 12:13
awk: cmd. line:1: {printf ...then in next line awk: cmd. line:1: ^ unexpected newline or end of string
â Nayak
Jul 9 at 12:13
 |Â
show 1 more comment
1
post a testable input fragment
â RomanPerekhrest
Jun 27 at 11:59
USe
tac some_directory/*.pre | grep -im1 "vdr" | cut -c129-132
â Arushix
Jun 27 at 12:05
Which shell are you using?
â andcoz
Jun 27 at 12:31
its exponential of
-3
output will be 0.00171â SivaPrasath
Jun 27 at 12:50