8 ms·
Because awk understands "columns" better. echo '999 888' | awk '{print $2}' prints 888
by efrecon 1y ago
Because awk understands "columns" better.
echo '999 888' | awk '{print $2}'
prints 888
- cluckindan 1y agoHow is that different from echo '999 888' | cut -f2 -d " " except for the default delimiter being space for awk?
- Eduard 1y agoecho '999 888' | cut -f2 -d " " # notice two consecutive spaces returns NULL.
- cluckindan 1y agoRight, that would be expected though? I suppose awk is better for parsing formatted (padded) output.
- xorcist 1y agoThere are invalid column separators for awk too. To handle consecutive spaces in cut you have squeeze them: echo '999 888' | tr -s " " | cut -f2 -d " "
- bregma 1y agoHow can it be "better" when it is exactly the same?