| Thread Closed |
Unix Shell Script |
Share Thread | Thread Tools |
| May24-07, 06:40 PM | #1 |
|
|
Unix Shell Script
I have never written a shell script, but I am trying to learn. I want to make a generic Unix shell script that will allow me to run four commands in a row... something like this...
latex $filename bibtex $filename latex $filename latex $filename I would like to call the script "ltxprc.sh". How would I make this file work for any filename? For instance, if my file name were "paper", would I run a command like... sh ltxprc.sh where do I input the filename? |
| May24-07, 06:55 PM | #2 |
|
Mentor
|
First, you need to modify your script so it accesses the command line arguments sent to the script:
filename=$1 You pass the filename on the command line: sh ltxprc.sh file.tex Even better is to make the shell script executable via chmod. You will need to add a "shebang" line to the very front of your script: #!/bin/sh When you do that, all you need to say is ltxprc.sh file.tex |
| May25-07, 02:26 PM | #3 |
|
|
Thanks for the help. That was probably the most useful response I have ever received from a message board.
I gotta ask... why is it that the #!/bin/sh works? I thought that the # symbol meant "comment out" that which follows. |
| May25-07, 03:09 PM | #4 |
|
Mentor
|
Unix Shell ScriptFor more info, see http://homepages.cwi.nl/~aeb/std/hashexclam.html and http://en.wikipedia.org/wiki/Shebang_%28Unix%29. |
| Thread Closed |
| Thread Tools | |
Similar Threads for: Unix Shell Script
|
||||
| Thread | Forum | Replies | ||
| Shell scripting in C (unix) | Programming & Comp Sci | 19 | ||
| script similar to [tex] | General Discussion | 2 | ||
| post script | Computing & Technology | 2 | ||
| [SOLVED] on shell, off shell - what does it mean | General Physics | 7 | ||