IceMan
0
Q:

write a bash script that accepts a text file as argument and calculates number of occurrences of each words in it and return them as key value pairs

file=/home/stefan/ooxml1.txt
for word in $(sed 's/[^A-Za-z]/ /g' $file | tr " " "\n" | sort -u)
do
  echo -n "$word "
  grep -c $word $file
done | sort -k2 -n 
0

New to Communities?

Join the community