Re: man page for cut

2024-01-17 Thread Tom Furie
Richmond  writes:

> 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 is used with the long-form option, not the short-form.



Re: man page for cut

2024-01-17 Thread Dan Ritter
Richmond wrote: 
> echo hello|cut -b=2-5
> cut: invalid byte/character position ‘=2-5’
> Try 'cut --help' for more information.
> 
> Why is this?
> 
> (An example paints a thousand words).

$ echo hello|cut -b 2-5
ello

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

-dsr-



Re: man page for cut

2024-01-17 Thread Tixy
On Wed, 2024-01-17 at 17:26 +, 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



man page for cut

2024-01-17 Thread Richmond
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?

(An example paints a thousand words).