Advertisement

A script in linux?

Started by November 19, 2005 07:39 AM
4 comments, last by GameDev.net 18 years, 10 months ago
I noticed that I can create a text file with a command in it, and when I run this text file in the terminal it will run the command in it. However, when I write more then one command, it will run only the first one. How do I make such script that will run all the commands in the text file and wont run the next command before the first has finished. Thanks in advance.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote: Original post by Toolmaker Quote: Original post by The C modest godHow is my improoved signature?It sucks, just like you.
Just put this on the first line:
#!/bin/bash
___________________________Buggrit, millennium hand and shrimp!
Advertisement
A quick guide to writing scripts using the bash shell.

Basically, the first line of the file needs to be:
#!/bin/bash


You have your commands after that. The file also needs to be marked as executable (run: chmod u+x <the file>) to make it executable by your user account.

Note that bash isn't the only shell that you could write scripts for, but I think it's the most likely one to be available.

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
You can also execute multiple functions in one line. I'm referring to piping and just multiple functions in one line:

PIPING:

echo Hello, world | cut -f1 -d, > output.txt

MULTIPLE COMMANDS:

./func1 && ./func2

equivalent to ...

          |./func1 <-|          |./func2 <-|
"Take delight in the Lord and He will give you your heart's desires" - Psalm 37:4My Blog
Quote: Original post by JohnBSmall
Note that bash isn't the only shell that you could write scripts for, but I think it's the most likely one to be available.


I'd think /bin/sh would be even more likely...

Quote: Original post by me22
Quote: Original post by JohnBSmall
Note that bash isn't the only shell that you could write scripts for, but I think it's the most likely one to be available.


I'd think /bin/sh would be even more likely...


especially of you want it to run on more than just Linux... FreeBSD puts bash in /usr/local/bin/bash, if it's installed at all.

This topic is closed to new replies.

Advertisement