Issue
I am trying this:
echo "This is test" | cut -f 1
and it is not cutting anything, I get this:
This is test
id='dv3'>
Solution
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"
Answered By - Mark Reed Answer Checked By - Senaida (WPSolving Volunteer)