LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-18-2015, 10:56 AM   #1
barbac
LQ Newbie
 
Registered: Jun 2015
Posts: 2

Rep: Reputation: Disabled
Executing bash scripts. Differences beetween ./ and . ./


Hello!

What is the main difference about executing bash script with "./" and ". ./"?
 
Old 06-18-2015, 11:08 AM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,364

Rep: Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004
"./script" is the same as "/path/to/script", which is the same as adding the script's directory to your PATH and running "script". It runs the script in a subshell. All of the lines are executed, but any variables that are set are lost once it finishes and returns to your shell.

". ./script" is the same as ". script", which is the same as "source script", which is the same as "source /path/to/script". It runs the script in your current shell. All of the lines are executed, and any variables that are set are retained in your shell once it finishes.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems executing scripts Lindy70 Linux - Newbie 2 05-07-2012 01:16 PM
Executing scripts jonette20 Linux - General 3 10-15-2007 02:50 PM
executing Bash Scripts c4nk Linux - General 3 03-11-2007 05:52 PM
CGI Scripts not executing Mr_Oz Linux - Enterprise 7 04-18-2006 04:21 PM
Executing scripts upon login jungatheart Linux - Newbie 3 04-19-2004 07:06 PM


All times are GMT -5. The time now is 10:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration