On Wed, 2024-01-17 at 17:26 +0000, Richmond wrote:
> In the man page for cut it says:
> 
>  -b, --bytes=LIST
>               select only these bytes
> 
> But there is no equals sign in the actual syntax:
> 
> echo hello|cut -b 2-5
> ello
> 
> echo hello|cut -b=2-5
> cut: invalid byte/character position ‘=2-5’
> Try 'cut --help' for more information.
> 
> Why is this?
> 

The equals sign only applies to the 'long form' of the option...

$echo hello|cut --bytes=2-5
ello

This is standard behaviour for a lot of utilities.

A hyphen and single letter is the 'short form' and there is an optional
space between the letter and it's arguments.

A double hyphen and and option name has an '=' separating it from and
arguments.

For the short form, you can often (usually?) merge multiple option
letters and any argument at the end applies to the last option letter.

$echo hello|cut -zb2-5
ello$

(the 'z' option says use NUL byte for line terminator so in this case
it didn't output the newline and my '$' command prompt got printed
straight after the 'ello'.

-- 
Tixy

Reply via email to