Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

How to execute a bash file in terminal?

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-05-2007
Hyunkel Hyunkel is offline
Registered User
 
Join Date: Sep 2007
Last Activity: 5 October 2007, 10:14 PM EDT
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 Unix and Linux 10-06-2007
maximas maximas is offline
Registered User
 
Join Date: Sep 2007
Last Activity: 2 March 2009, 12:44 AM EST
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 755Linux
Sponsored Links
    #3  
Old Unix and Linux 10-06-2007
tomas's Unix or Linux Image
tomas tomas is offline
Registered User
 
Join Date: Sep 2007
Last Activity: 17 December 2007, 1:58 PM EST
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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 11:54 PM.