I am new to grep and awk, and I would like to create tabs separated by values โโin the "frequency.txt" file (this script looks at a large case and then displays each individual word and how many times it is used in the case - I modified it for Khmer language). I looked ( grep tab on UNIX ), but I can not find an example that makes sense to me for this bash script (I'm too many newbies).
I use this bash script in cygwin:
#!/bin/bash
echo Creating tally of word frequencies...
sed -e 's/[a-zA-Z]//g' -e 's/โ/ /g' -e 's/\t/ /g' \
-e 's/[ยซ|ยป|:|;|.|,|(|)|-|?|แ|"|"]//g' -e 's/[0-9]//g' \
-e 's/ /\n/g' -e 's/แ //g' -e 's/แก//g' -e 's/แข//g' \
-e 's/แฃ//g' -e 's/แค//g' -e 's/แฅ//g' -e 's/แฆ//g' \
-e 's/แง//g' -e 's/แจ//g' -e 's/แฉ//g' dictionary.txt | \
tr [:upper:] [:lower:] | \
sort | \
uniq -c | \
sort -rn > frequency.txt
grep -Fwf dictionary.txt frequency.txt | awk '{print $2 "," $1}'
Awk prints with a comma, but it is only on the screen. How can I put a tab (a comma will also work), between frequency and term?
dictionary.txt(Khmer , , sed , ):
แแแ แ แแทแแแแถแ แแนแ แแแแแแแ แแแแแ แแแแธ แแแ แแถ แขแแแแพแ แแ แ แพแ แขแแแ แแถ แแแ แฎ แแ แแถ แขแแแแพแ แแ แแแ แขแแแ แแถ แแแ แแแแแ แ แแ แแถแ แแ แแ แ แพแ แขแแแ แแถ แแแ แ
แแ แแถแ แแถแ แแ แแ แแนแ แแธแแทแ แ แแ แ
แปแ แฅแ แ
แแ แแแแ แแ.
frequency.txt, ( ):
25605 แแนแ 25043 แแถ 22004 แแถแ 20515 แ แแ
, frequency.txt ( TAB ):
25605TAB แแนแ 25043TAB แแถ 22004TAB แแถแ 20515TAB แ แแ
!