2

I created a .csv file (separated by ; instead of ,) that includes movie titles, movie rankings, movie years, and imdb rating from http://www.imdb.com/chart/top. Now I am trying to figure out how many movies were released before a given year. The year will be determined by the first shell input argument. Here is what I have so far:

awk -F "\"*;\"*" '$4 < 1950 {print ;}' result.csv | more | wc -l

Instead of "1950", I need it to be the first shell argument ($1). Using $1 instead of 1950 is telling the machine to compare the 4th column to the 1st column. I need to compare the 4th column with the 1st argument.

I need to run the file with the 1st argument being 1950:

./filename.sh 1950 
0

2 Answers 2

1
awk -F '"*;"*' -v d="$1" '$4 < d' result.csv
Sign up to request clarification or add additional context in comments.

Comments

0

you can do counting in awk as well

awk -F'"*;"*' -v year=$1 '$4<year{count++} END{print count}' file

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.