white space in ZFS command line
![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
2
down vote
favorite
I have found that white space seems to be significant in ZFS commands, but only apparently under some conditions.. For example, both of the following commands work:
root@grandidier:~# zfs list -t snap -r tank/srv
NAME USED AVAIL REFER MOUNTPOINT
tank/srv@initial 4.22G - 2.45T -
tank/srv@2018-01-09 106G - 3.40T -
tank/srv@2018-01-14 50.0M - 3.27T -
tank/srv@2018-01-17 48.8M - 3.16T -
tank/srv@2018-01-19 56.9M - 3.09T -
tank/srv@2018-01-30 48.6M - 2.72T -
tank/srv@2018-02-12 104M - 2.49T -
root@grandidier:~# zfs list -t snap -r tank/srv
NAME USED AVAIL REFER MOUNTPOINT
tank/srv@initial 4.22G - 2.45T -
tank/srv@2018-01-09 106G - 3.40T -
tank/srv@2018-01-14 50.0M - 3.27T -
tank/srv@2018-01-17 48.8M - 3.16T -
tank/srv@2018-01-19 56.9M - 3.09T -
tank/srv@2018-01-30 48.6M - 2.72T -
tank/srv@2018-02-12 104M - 2.49T -
root@grandidier:~#
(Note: added space between "...snap -r") However if I put the command in a pipe and use back tick substitution to get the result of the command, I get:
root@grandidier:~# export NEW=`zfs list -t snap -r tank/srv | tail -1 | awk 'print $1'`; echo $NEW
tank/srv@2018-02-12
root@grandidier:~# export NEW=`zfs list -t snap ÃÂ -r tank/srv | tail -1 | awk 'print $1'`; echo $NEW
cannot open 'ÃÂ -r': invalid dataset name
cannot open 'tank/srv': operation not applicable to datasets of this type
root@grandidier:~#
I find this baffling and disconcerting. I think I can sidestep the issue by crafting my scripts without any extra white space but I'd really like to know why this is happening in the first place.
This is on
Ubuntu 16.04 LTS (up to date)
bash 4.3.48
ZFS 0.6.5.11-1ubuntu3
Edit: to answer the first three comments (and retain code formatting)
root@grandidier:~/bin# printf '%qn' "$IFS"
$' tn'
It seems that the $(...) syntax is also subject to this problem (see next comment.)
I'm not sure where something that looks like a space could come from but it seems that is the issue. I have copied this string to/from a Google doc and perhaps it did some sort of translation on the spaces. If I add the extra space in the google doc and copy/paste to an xterm, the error is reported. If I edit the command (on the command line) and delete/reenter the two spaces, the command works w/out error.
Clearly Google Docs is not a good programming editor. (I'm not really using it that way but rather to take notes and save copies of commands as I work my way through something. I probably should stick to something like vim for that.)
command-line bash zfs
 |Â
show 1 more comment
up vote
2
down vote
favorite
I have found that white space seems to be significant in ZFS commands, but only apparently under some conditions.. For example, both of the following commands work:
root@grandidier:~# zfs list -t snap -r tank/srv
NAME USED AVAIL REFER MOUNTPOINT
tank/srv@initial 4.22G - 2.45T -
tank/srv@2018-01-09 106G - 3.40T -
tank/srv@2018-01-14 50.0M - 3.27T -
tank/srv@2018-01-17 48.8M - 3.16T -
tank/srv@2018-01-19 56.9M - 3.09T -
tank/srv@2018-01-30 48.6M - 2.72T -
tank/srv@2018-02-12 104M - 2.49T -
root@grandidier:~# zfs list -t snap -r tank/srv
NAME USED AVAIL REFER MOUNTPOINT
tank/srv@initial 4.22G - 2.45T -
tank/srv@2018-01-09 106G - 3.40T -
tank/srv@2018-01-14 50.0M - 3.27T -
tank/srv@2018-01-17 48.8M - 3.16T -
tank/srv@2018-01-19 56.9M - 3.09T -
tank/srv@2018-01-30 48.6M - 2.72T -
tank/srv@2018-02-12 104M - 2.49T -
root@grandidier:~#
(Note: added space between "...snap -r") However if I put the command in a pipe and use back tick substitution to get the result of the command, I get:
root@grandidier:~# export NEW=`zfs list -t snap -r tank/srv | tail -1 | awk 'print $1'`; echo $NEW
tank/srv@2018-02-12
root@grandidier:~# export NEW=`zfs list -t snap ÃÂ -r tank/srv | tail -1 | awk 'print $1'`; echo $NEW
cannot open 'ÃÂ -r': invalid dataset name
cannot open 'tank/srv': operation not applicable to datasets of this type
root@grandidier:~#
I find this baffling and disconcerting. I think I can sidestep the issue by crafting my scripts without any extra white space but I'd really like to know why this is happening in the first place.
This is on
Ubuntu 16.04 LTS (up to date)
bash 4.3.48
ZFS 0.6.5.11-1ubuntu3
Edit: to answer the first three comments (and retain code formatting)
root@grandidier:~/bin# printf '%qn' "$IFS"
$' tn'
It seems that the $(...) syntax is also subject to this problem (see next comment.)
I'm not sure where something that looks like a space could come from but it seems that is the issue. I have copied this string to/from a Google doc and perhaps it did some sort of translation on the spaces. If I add the extra space in the google doc and copy/paste to an xterm, the error is reported. If I edit the command (on the command line) and delete/reenter the two spaces, the command works w/out error.
Clearly Google Docs is not a good programming editor. (I'm not really using it that way but rather to take notes and save copies of commands as I work my way through something. I probably should stick to something like vim for that.)
command-line bash zfs
1
What is the value of $IFS? You can runprintf '%qn' "$IFS"
to find out.
â wjandrea
Feb 13 at 18:22
Try using the newer command substitution syntax$()
instead of backticks.
â wjandrea
Feb 13 at 18:22
1
That second space in the second example is probably not an actual space but an NBSP or similar Unicode space
â muru
Feb 13 at 22:36
1
Yep, Google Docs would be it. Any "rich text" editor would cause problems with code, such as converting--
to en-dashes, normal spaces to NBSP, normal quotes to pretty quotes, etc. Maybe use a monospace font or something.
â muru
Feb 14 at 2:15
1
Looks like it's been converted into a regular space in your question. If you want to find out what Unicode character it is, you can pipe the string intouniname
, likeecho "ÃÂ " | uniname
(this is an example with two regular spaces).
â wjandrea
Feb 14 at 19:49
 |Â
show 1 more comment
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have found that white space seems to be significant in ZFS commands, but only apparently under some conditions.. For example, both of the following commands work:
root@grandidier:~# zfs list -t snap -r tank/srv
NAME USED AVAIL REFER MOUNTPOINT
tank/srv@initial 4.22G - 2.45T -
tank/srv@2018-01-09 106G - 3.40T -
tank/srv@2018-01-14 50.0M - 3.27T -
tank/srv@2018-01-17 48.8M - 3.16T -
tank/srv@2018-01-19 56.9M - 3.09T -
tank/srv@2018-01-30 48.6M - 2.72T -
tank/srv@2018-02-12 104M - 2.49T -
root@grandidier:~# zfs list -t snap -r tank/srv
NAME USED AVAIL REFER MOUNTPOINT
tank/srv@initial 4.22G - 2.45T -
tank/srv@2018-01-09 106G - 3.40T -
tank/srv@2018-01-14 50.0M - 3.27T -
tank/srv@2018-01-17 48.8M - 3.16T -
tank/srv@2018-01-19 56.9M - 3.09T -
tank/srv@2018-01-30 48.6M - 2.72T -
tank/srv@2018-02-12 104M - 2.49T -
root@grandidier:~#
(Note: added space between "...snap -r") However if I put the command in a pipe and use back tick substitution to get the result of the command, I get:
root@grandidier:~# export NEW=`zfs list -t snap -r tank/srv | tail -1 | awk 'print $1'`; echo $NEW
tank/srv@2018-02-12
root@grandidier:~# export NEW=`zfs list -t snap ÃÂ -r tank/srv | tail -1 | awk 'print $1'`; echo $NEW
cannot open 'ÃÂ -r': invalid dataset name
cannot open 'tank/srv': operation not applicable to datasets of this type
root@grandidier:~#
I find this baffling and disconcerting. I think I can sidestep the issue by crafting my scripts without any extra white space but I'd really like to know why this is happening in the first place.
This is on
Ubuntu 16.04 LTS (up to date)
bash 4.3.48
ZFS 0.6.5.11-1ubuntu3
Edit: to answer the first three comments (and retain code formatting)
root@grandidier:~/bin# printf '%qn' "$IFS"
$' tn'
It seems that the $(...) syntax is also subject to this problem (see next comment.)
I'm not sure where something that looks like a space could come from but it seems that is the issue. I have copied this string to/from a Google doc and perhaps it did some sort of translation on the spaces. If I add the extra space in the google doc and copy/paste to an xterm, the error is reported. If I edit the command (on the command line) and delete/reenter the two spaces, the command works w/out error.
Clearly Google Docs is not a good programming editor. (I'm not really using it that way but rather to take notes and save copies of commands as I work my way through something. I probably should stick to something like vim for that.)
command-line bash zfs
I have found that white space seems to be significant in ZFS commands, but only apparently under some conditions.. For example, both of the following commands work:
root@grandidier:~# zfs list -t snap -r tank/srv
NAME USED AVAIL REFER MOUNTPOINT
tank/srv@initial 4.22G - 2.45T -
tank/srv@2018-01-09 106G - 3.40T -
tank/srv@2018-01-14 50.0M - 3.27T -
tank/srv@2018-01-17 48.8M - 3.16T -
tank/srv@2018-01-19 56.9M - 3.09T -
tank/srv@2018-01-30 48.6M - 2.72T -
tank/srv@2018-02-12 104M - 2.49T -
root@grandidier:~# zfs list -t snap -r tank/srv
NAME USED AVAIL REFER MOUNTPOINT
tank/srv@initial 4.22G - 2.45T -
tank/srv@2018-01-09 106G - 3.40T -
tank/srv@2018-01-14 50.0M - 3.27T -
tank/srv@2018-01-17 48.8M - 3.16T -
tank/srv@2018-01-19 56.9M - 3.09T -
tank/srv@2018-01-30 48.6M - 2.72T -
tank/srv@2018-02-12 104M - 2.49T -
root@grandidier:~#
(Note: added space between "...snap -r") However if I put the command in a pipe and use back tick substitution to get the result of the command, I get:
root@grandidier:~# export NEW=`zfs list -t snap -r tank/srv | tail -1 | awk 'print $1'`; echo $NEW
tank/srv@2018-02-12
root@grandidier:~# export NEW=`zfs list -t snap ÃÂ -r tank/srv | tail -1 | awk 'print $1'`; echo $NEW
cannot open 'ÃÂ -r': invalid dataset name
cannot open 'tank/srv': operation not applicable to datasets of this type
root@grandidier:~#
I find this baffling and disconcerting. I think I can sidestep the issue by crafting my scripts without any extra white space but I'd really like to know why this is happening in the first place.
This is on
Ubuntu 16.04 LTS (up to date)
bash 4.3.48
ZFS 0.6.5.11-1ubuntu3
Edit: to answer the first three comments (and retain code formatting)
root@grandidier:~/bin# printf '%qn' "$IFS"
$' tn'
It seems that the $(...) syntax is also subject to this problem (see next comment.)
I'm not sure where something that looks like a space could come from but it seems that is the issue. I have copied this string to/from a Google doc and perhaps it did some sort of translation on the spaces. If I add the extra space in the google doc and copy/paste to an xterm, the error is reported. If I edit the command (on the command line) and delete/reenter the two spaces, the command works w/out error.
Clearly Google Docs is not a good programming editor. (I'm not really using it that way but rather to take notes and save copies of commands as I work my way through something. I probably should stick to something like vim for that.)
command-line bash zfs
command-line bash zfs
edited Feb 14 at 2:07
asked Feb 13 at 15:40
HankB
214
214
1
What is the value of $IFS? You can runprintf '%qn' "$IFS"
to find out.
â wjandrea
Feb 13 at 18:22
Try using the newer command substitution syntax$()
instead of backticks.
â wjandrea
Feb 13 at 18:22
1
That second space in the second example is probably not an actual space but an NBSP or similar Unicode space
â muru
Feb 13 at 22:36
1
Yep, Google Docs would be it. Any "rich text" editor would cause problems with code, such as converting--
to en-dashes, normal spaces to NBSP, normal quotes to pretty quotes, etc. Maybe use a monospace font or something.
â muru
Feb 14 at 2:15
1
Looks like it's been converted into a regular space in your question. If you want to find out what Unicode character it is, you can pipe the string intouniname
, likeecho "ÃÂ " | uniname
(this is an example with two regular spaces).
â wjandrea
Feb 14 at 19:49
 |Â
show 1 more comment
1
What is the value of $IFS? You can runprintf '%qn' "$IFS"
to find out.
â wjandrea
Feb 13 at 18:22
Try using the newer command substitution syntax$()
instead of backticks.
â wjandrea
Feb 13 at 18:22
1
That second space in the second example is probably not an actual space but an NBSP or similar Unicode space
â muru
Feb 13 at 22:36
1
Yep, Google Docs would be it. Any "rich text" editor would cause problems with code, such as converting--
to en-dashes, normal spaces to NBSP, normal quotes to pretty quotes, etc. Maybe use a monospace font or something.
â muru
Feb 14 at 2:15
1
Looks like it's been converted into a regular space in your question. If you want to find out what Unicode character it is, you can pipe the string intouniname
, likeecho "ÃÂ " | uniname
(this is an example with two regular spaces).
â wjandrea
Feb 14 at 19:49
1
1
What is the value of $IFS? You can run
printf '%qn' "$IFS"
to find out.â wjandrea
Feb 13 at 18:22
What is the value of $IFS? You can run
printf '%qn' "$IFS"
to find out.â wjandrea
Feb 13 at 18:22
Try using the newer command substitution syntax
$()
instead of backticks.â wjandrea
Feb 13 at 18:22
Try using the newer command substitution syntax
$()
instead of backticks.â wjandrea
Feb 13 at 18:22
1
1
That second space in the second example is probably not an actual space but an NBSP or similar Unicode space
â muru
Feb 13 at 22:36
That second space in the second example is probably not an actual space but an NBSP or similar Unicode space
â muru
Feb 13 at 22:36
1
1
Yep, Google Docs would be it. Any "rich text" editor would cause problems with code, such as converting
--
to en-dashes, normal spaces to NBSP, normal quotes to pretty quotes, etc. Maybe use a monospace font or something.â muru
Feb 14 at 2:15
Yep, Google Docs would be it. Any "rich text" editor would cause problems with code, such as converting
--
to en-dashes, normal spaces to NBSP, normal quotes to pretty quotes, etc. Maybe use a monospace font or something.â muru
Feb 14 at 2:15
1
1
Looks like it's been converted into a regular space in your question. If you want to find out what Unicode character it is, you can pipe the string into
uniname
, like echo "ÃÂ " | uniname
(this is an example with two regular spaces).â wjandrea
Feb 14 at 19:49
Looks like it's been converted into a regular space in your question. If you want to find out what Unicode character it is, you can pipe the string into
uniname
, like echo "ÃÂ " | uniname
(this is an example with two regular spaces).â wjandrea
Feb 14 at 19:49
 |Â
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f1005849%2fwhite-space-in-zfs-command-line%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
What is the value of $IFS? You can run
printf '%qn' "$IFS"
to find out.â wjandrea
Feb 13 at 18:22
Try using the newer command substitution syntax
$()
instead of backticks.â wjandrea
Feb 13 at 18:22
1
That second space in the second example is probably not an actual space but an NBSP or similar Unicode space
â muru
Feb 13 at 22:36
1
Yep, Google Docs would be it. Any "rich text" editor would cause problems with code, such as converting
--
to en-dashes, normal spaces to NBSP, normal quotes to pretty quotes, etc. Maybe use a monospace font or something.â muru
Feb 14 at 2:15
1
Looks like it's been converted into a regular space in your question. If you want to find out what Unicode character it is, you can pipe the string into
uniname
, likeecho "ÃÂ " | uniname
(this is an example with two regular spaces).â wjandrea
Feb 14 at 19:49