Help with Unix and Awk to count number of occurrences

Hi,

I have a file (movies.sh), this file contains list of movies such as

I want to redirect the movies from movies.sh to file_to_process to allow me process the file with out losing anything.

I have tried

Movies.sh >> file_to_process 

But I want to add the row number to the data going to file to process. Like in AWK NR
Also I would like to process the (file_to_process) to get the number of occurrences for each movie for example

As I don't want to same movie printed again and again.

will anyone be able to help with this?

This seems very confused. A file containing a list of movies is not a shell script and shouldn't be run, and I don't know why you're appending the output with >> instead of replacing with >.

If you want to add line numbers:

awk '{ print NR, $0 }' filename > newfile

Looking for something like this?

$ sed 1d filename | sort | uniq -c
      1 Absence of Malice 1981
      1 Adam's Rib 1949
      3 Adaptation 2002
      1 Affliction 1998
      1 The Adjuster 1991
      2 The Adventures of Robin Hood 1938
1 Like