Can not echo entire line to file
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
I can not figure out how to get the following line echoed to a file.
Only part of it makes it into the file.
echo perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);">>Show_Percent_Reserved_Blocks.sh
When I run the script below this, I get
andyk_~/Downloads$ Show_Percent_Reserved_Blocks.sh
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 2: Block: command not found
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 3: Reserved: command not found
syntax error at -e line 1, near "/ )"
Execution of -e aborted due to compilation errors.
#!/bin/bash
Block count: 421958912
Reserved block count: 4219589
perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"
command-line bash
add a comment |Â
up vote
1
down vote
favorite
I can not figure out how to get the following line echoed to a file.
Only part of it makes it into the file.
echo perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);">>Show_Percent_Reserved_Blocks.sh
When I run the script below this, I get
andyk_~/Downloads$ Show_Percent_Reserved_Blocks.sh
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 2: Block: command not found
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 3: Reserved: command not found
syntax error at -e line 1, near "/ )"
Execution of -e aborted due to compilation errors.
#!/bin/bash
Block count: 421958912
Reserved block count: 4219589
perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"
command-line bash
1
Which part makes it into the file? Please edit the question to clarify.
â wjandrea
Jun 11 at 21:16
1
Your edits seem to be about different issues, namely that you've got two non-command lines in the file, and a syntax error in the Perl command. Please ask new question, and make sure to clarify what you're expecting to happen.
â wjandrea
Jun 12 at 1:21
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I can not figure out how to get the following line echoed to a file.
Only part of it makes it into the file.
echo perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);">>Show_Percent_Reserved_Blocks.sh
When I run the script below this, I get
andyk_~/Downloads$ Show_Percent_Reserved_Blocks.sh
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 2: Block: command not found
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 3: Reserved: command not found
syntax error at -e line 1, near "/ )"
Execution of -e aborted due to compilation errors.
#!/bin/bash
Block count: 421958912
Reserved block count: 4219589
perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"
command-line bash
I can not figure out how to get the following line echoed to a file.
Only part of it makes it into the file.
echo perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);">>Show_Percent_Reserved_Blocks.sh
When I run the script below this, I get
andyk_~/Downloads$ Show_Percent_Reserved_Blocks.sh
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 2: Block: command not found
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 3: Reserved: command not found
syntax error at -e line 1, near "/ )"
Execution of -e aborted due to compilation errors.
#!/bin/bash
Block count: 421958912
Reserved block count: 4219589
perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"
command-line bash
edited Jun 11 at 21:59
![](https://i.stack.imgur.com/6SRsM.jpg?s=32&g=1)
![](https://i.stack.imgur.com/6SRsM.jpg?s=32&g=1)
dadexix86
5,3622492
5,3622492
asked Jun 11 at 21:03
![](https://i.stack.imgur.com/e3cCX.jpg?s=32&g=1)
![](https://i.stack.imgur.com/e3cCX.jpg?s=32&g=1)
fixit7
435316
435316
1
Which part makes it into the file? Please edit the question to clarify.
â wjandrea
Jun 11 at 21:16
1
Your edits seem to be about different issues, namely that you've got two non-command lines in the file, and a syntax error in the Perl command. Please ask new question, and make sure to clarify what you're expecting to happen.
â wjandrea
Jun 12 at 1:21
add a comment |Â
1
Which part makes it into the file? Please edit the question to clarify.
â wjandrea
Jun 11 at 21:16
1
Your edits seem to be about different issues, namely that you've got two non-command lines in the file, and a syntax error in the Perl command. Please ask new question, and make sure to clarify what you're expecting to happen.
â wjandrea
Jun 12 at 1:21
1
1
Which part makes it into the file? Please edit the question to clarify.
â wjandrea
Jun 11 at 21:16
Which part makes it into the file? Please edit the question to clarify.
â wjandrea
Jun 11 at 21:16
1
1
Your edits seem to be about different issues, namely that you've got two non-command lines in the file, and a syntax error in the Perl command. Please ask new question, and make sure to clarify what you're expecting to happen.
â wjandrea
Jun 12 at 1:21
Your edits seem to be about different issues, namely that you've got two non-command lines in the file, and a syntax error in the Perl command. Please ask new question, and make sure to clarify what you're expecting to happen.
â wjandrea
Jun 12 at 1:21
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
5
down vote
accepted
The problem is that as you've used double quotes, the variable references ($reserved_block_count
, $block_count
) are being expanded in the current (invoking) shell environment; you need to quote the whole thing with single quotes around:
echo 'perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"' >>Show_Percent_Reserved_Blocks.sh
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
The problem is that as you've used double quotes, the variable references ($reserved_block_count
, $block_count
) are being expanded in the current (invoking) shell environment; you need to quote the whole thing with single quotes around:
echo 'perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"' >>Show_Percent_Reserved_Blocks.sh
add a comment |Â
up vote
5
down vote
accepted
The problem is that as you've used double quotes, the variable references ($reserved_block_count
, $block_count
) are being expanded in the current (invoking) shell environment; you need to quote the whole thing with single quotes around:
echo 'perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"' >>Show_Percent_Reserved_Blocks.sh
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
The problem is that as you've used double quotes, the variable references ($reserved_block_count
, $block_count
) are being expanded in the current (invoking) shell environment; you need to quote the whole thing with single quotes around:
echo 'perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"' >>Show_Percent_Reserved_Blocks.sh
The problem is that as you've used double quotes, the variable references ($reserved_block_count
, $block_count
) are being expanded in the current (invoking) shell environment; you need to quote the whole thing with single quotes around:
echo 'perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"' >>Show_Percent_Reserved_Blocks.sh
answered Jun 11 at 21:07
![](https://i.stack.imgur.com/8mGqv.gif?s=32&g=1)
![](https://i.stack.imgur.com/8mGqv.gif?s=32&g=1)
heemayl
63.5k8126202
63.5k8126202
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1045727%2fcan-not-echo-entire-line-to-file%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Which part makes it into the file? Please edit the question to clarify.
â wjandrea
Jun 11 at 21:16
1
Your edits seem to be about different issues, namely that you've got two non-command lines in the file, and a syntax error in the Perl command. Please ask new question, and make sure to clarify what you're expecting to happen.
â wjandrea
Jun 12 at 1:21