Variables exercise - awk #22
-
I found a solution for the exercise in page #8, the following code gives the result =15 awk -F "\t" ' { if($3 = "Bottled Water") print $2}' orders.tsv > temp1 | sort -nr temp1 | awk -F "\t" '{ if(NR == 1) print $1 }' temp1 > largest_order.tsv but the website does not pick it up as resolved. If someone obtained an approved result can you share it please ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @eugeniadamato, A few things to look into:
guest@sandbox$ wc -l orders.tsv
4623 orders.tsv
guest@sandbox$ awk -F "\t" ' { if($3 = "Bottled Water") print $2}' orders.tsv | wc -l
4623
Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
it works for me with: |
Beta Was this translation helpful? Give feedback.
Hi @eugeniadamato,
A few things to look into:
if($3 = "Bottled Water")
. It's supposed to only keep rows where the 3rd column is Bottled Water. BUT if you calculate the number of lines after filtering, you'll see it's exactly the same as without filtering, so something is off:orders.tsv > temp1 | sort
, the issue is you shouldn't mix both patterns ofcommand > file
andcommand | command
. You can either rewrite this so there's no> temp1
and you keep piping the output ofawk
tosort
directly withou…