#!/bin/sh
# By using [*]+ as field separator, strip them all out and
# get them as sane tokens.
# By using OFS="\n", print one name per line.
# ORS="" prevents a few extra newlines.
# $1=$1 is necessary to actually transform the data, which isn't otherwise modified.
file1 < awk -v FS="[*]+" -v OFS="\n" -v ORS="" '{ $1=$1 ; NF--; } 1' |
# Sort alphabetically
sort |
# Count repetitions, save output to temp file.
uniq -c > /tmp/$$
# Read the sorted file, and output it in the manner we need.
while read COUNT NAME
do
# Ignore blank first line
[ -z "$NAME" ] && continue
echo "$NAME = $COUNT"
echo "$NAME" >&2
done < /tmp/$$ > file2 2> file3
# delete temp file.
rm -f /tmp/$$
It is, but so was mine. I meant "< file1" instead of "> file1".
Your script will try to run a command named "file1" with standard input redirected from a file named "awk". The operator needs to precede the filename.