I am constantly running commands like
nohup psql -d db -f foo1.sql >& foo1.out &
nohup psql -d db -f foo2.sql >& foo2.out &
I was wondering how to create a shellscript that takes as input the filename parameter like foo1.sql and runs the command above.
How do I write a script called test so that the command ./test foo1.sql
will execute the command
nohup psql -d db -f foo1.sql >& foo1.out &
The syntax for calling the scripts would be:
there is a shell built-in called
test
, so don't call your script that. No parentheses required when passing parameters.The script is very simple:
Try this
It's not called with
./test(foo1.sql)
but./test foo1.sql
, as shown after the question was edited.