I am trying this:
echo "This is test" | cut -f 1
and it is not cutting anything, I get this:
This is test
By default, cut
doesn't split on space, only on tab. If you tell it to split on space, then it won't split on tab. Also, consecutive spaces or tabs will add empty fields to the set.
If you want to split on "any amount of any kind of whitespace", you're better off with awk
:
echo "This is a test" | awk '{print $1}'
Also, you can replace echo
...|
with <<<
in bash:
awk '{print $1}' <<<"This is a test"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With