0

I have a shell script (count_reviews.sh) that contains the following:

#!/bin/bash
grep -c "Author" "#1"

I have tried using "$1" as I found that this takes the first argument in the command line but I still get the error mentioned below. I have also used chmod +x to make my file executable.

The script counts the number of times "Author" appears in the file. I am required to be able to make the command line take an input of "% ./count_reviews.sh hotel_72572.dat" where hotel_72572.dat is an example file name. The number of times author appears will then be printed out underneath. When I do this however, I am getting an error -bash: fg: %: no such job. What is causing this and how do I fix it? My count_reviews.sh file is in the same directory as all of my hotel data files if that matters.

John Smith
  • 679
  • 1
  • 9
  • 17
  • The `%` is a common default prompt used in the c-shell (csh), I'm wondering if that's where it came from (others, like bash, use `$` for ordinary users, `#` for root). – cdarke Feb 15 '16 at 22:58

1 Answers1

1

You should indeed use $1, but when you try to run your script just use ./your_script.sh your_argument don't add the % in the beginning.

haltode
  • 618
  • 6
  • 15