-2

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.

Something like this:

cat ciao | rev | cut -d' ' -f1 | rev

would not work because I lose the number information. lol hi test ciao lo

Allexj
  • 1,375
  • 6
  • 14
  • 29

1 Answers1

0

I found an answer: I can do this:

cat ciao | rev | cut -d ' ' -f 1,2 | rev

to not lose the number information. works!

Allexj
  • 1,375
  • 6
  • 14
  • 29