Skip to main content
1 of 2
Allexj
  • 265
  • 2
  • 13

How to use cut to trim the first x variable spaces

I have a file that is like this:

              67 lol
             143 hi
              21 test
               1 ciao
               5 lo

I want to remove the spaces.

67 lol
143 hi
21 test
1 ciao
5 lo

I know that I can use sed to do that, for example with:

cat ciao | sed 's/[[:space:]]*\([[:digit:]]* .*\)/\1/' | sort -g

but my professor says that I can easily use cut to do that... but I really don't know how.

Allexj
  • 265
  • 2
  • 13