Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-05-2007
Registered User
 
Join Date: Sep 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
How to execute a bash file in terminal?

How do I execute a bash file in the terminal, after I created one?
Sponsored Links
    #2  
Old 10-06-2007
Registered User
 
Join Date: Sep 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
simple type bash space and the file name
$ bash bar
$ sh bar
$ ./bar
if ur using ./ means ten u hav to change the premission chmod 755
Sponsored Links
    #3  
Old 10-06-2007
tomas's Avatar
Registered User
 
Join Date: Sep 2007
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
the standard method for calling the shell for a script is to declare it in the first line of the file. Also called the shebang #!

file: demo.sh

Code:
#!/bin/bash
echo Hello, world!

Change the file to executable and run it from the terminal.


Code:
$ chmod +x demo.sh
$ ./demo.sh
Hello, world!

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Opening a terminal with bash gaurab UNIX for Dummies Questions & Answers 8 05-05-2011 01:02 PM
Run bash script without terminal locoroco Shell Programming and Scripting 1 03-14-2011 08:35 PM
How to search a file in bash terminal? andrewust UNIX for Dummies Questions & Answers 2 11-25-2010 11:44 AM
bash script won't execute (Mac) compulsiveguile Shell Programming and Scripting 6 03-02-2010 12:48 AM
Execute command from terminal on remote machine Ranu Shell Programming and Scripting 0 10-09-2007 04:13 AM



All times are GMT -4. The time now is 05:46 PM.