Input file to bash script

Hi,

I have this script

Script.sh:

 
#!/bin/sh
 sed 's,\[20\],,g' input.dat > output .dat
 

But i want to run it witb different files. So i want the input file as an input argument to the script, how could i do that.

Running it like this:

 
> Script.sh input.dat

Remove the redirection entirely, so you can run it like

./script.sh < input > output

Or modify it like

sed ... <"$1" >"$2"

and run it like

./script.sh input output

Or just:

#!/bin/sh
filename="$1"    # input filename
 sed 's,\[20\],,g' "${filename}" > output.dat

Take care. Removed extra space character from " output .dat ". It will not work with that typo.