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
cut
can remove a fixed number of spaces only. – U. Windl Mar 07 '22 at 12:25