1
I am storing output of pig file in a directory
Which contains lines with multiple columns separated by delimiter \\u0001
.
Now in shell script I want to fetch 7th column field from the output.
I tried below commands however didn’t get required output:
cnt=`awk -F '^A' '{print $7,$1}' $f`
cnt=`cut -d'\\u0001' -f8 $f | awk '{s+=$0}END{print s+0}'`
How to achieve the same?
Here is sample file:
printf "c1\\u0001c2\\u0001c3\\u0001c4\\u0001c5\\u0001c6\\u0001c7\\u0001c8" > 001.txt
Can you expand your answer to explain what this code does and how it addresses the problem? Unexplained code is discouraged, because it doesn't teach the solution (and RTFM isn't a substitute). Your answers will attract more upvotes with some explanation. Thanks.
– fixer1234 – 2016-03-04T19:58:14.163This answer should have been explained. – MariusMatutiae – 2016-03-05T11:34:35.267
awk - the program – Bing Bang – 2016-03-10T17:03:52.393