-1

I have taken a course in that suddenly I saw this, I understood until the pipe but the options used after the pipe for the command cut are bit confusing

  • 4
  • 1
    Please try to write questions so that the question text itself is complete even without the title. It's a common practice and a good idea for at least two reasons: some readers automatically skip titles and read the question, which would lead to confusion here, since the actual pipe isn't in the question; and also it's easier to copy the code from the question text if necessary, since the title is a link, while the main text is not. – ilkkachu Sep 08 '21 at 08:29

1 Answers1

3

With -c cut selects only specified characters or ranges of characters separated by comas:

N      N'th byte, character or field, counted from 1

N- from N'th byte, character or field, to end of line

N-M from N'th to M'th (included) byte, character or field

-M from first to M'th (included) byte, character or field

so cut -c1-11,50- will print characters 1 to 11 and 50 to end of line from every line printed by ls -l.

So you will get the file permissions (first 11 characters) and the rest depends on length of your username, size of the files etc., but I assume the idea might be to print name of the file (using cut -f might be better if this was the goal, but generally parsing ls is not a good idea)?

  • With ast-open ls, you'd rather use ls --format='%(mode)s %(name)s, or ls --format='%(mode)s %(name)s%(linkop:case:?*: %(linkop)s %(linkpath)s:)s' to also get the -> target for symlinks. – Stéphane Chazelas Sep 08 '21 at 07:16
  • See also stat -Lns +mode -- * with zsh's stat or find ./* -prune -printf '%M %f\n' with GNU find or stat -c '%A %n' -- * with GNU stat. – Stéphane Chazelas Sep 08 '21 at 07:19