Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8274679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:47:37+00:00 2026-06-08T07:47:37+00:00

I am running linux 2.6. On bash shell, i would like to source a

  • 0

I am running linux 2.6. On bash shell, i would like to source a file. If i am in the current directory as the source file, then i can do

source abc.sh

But if i am on some other folder, i would so

source /path-to/abc.sh

I would like to capture whatever is typed after the command source on the command line in my script, So, for example, i want access to “abc.sh” and in the latter case, i want access to “/path-to/abc.sh” inside abc.sh

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:47:38+00:00Added an answer on June 8, 2026 at 7:47 am

    You are looking for the $BASH_SOURCE variable which contains currently processed script.

    For example if /tmp/a.sh is:

    echo $BASH_SOURCE
    

    Then:

    $ cd /tmp
    $ . a.sh
    a.sh
    $ . /tmp/a.sh
    /tmp/a.sh
    $ . ../tmp/a.sh
    ../tmp/a.sh
    

    You can find more on it in info bash.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a BASH/shell script, running on Linux, but it sometimes has a problem
I usually source a *.sh file in a bash terminal on linux like this
I want to change the directory in linux using bash file. Below is the
I have a C file running on Linux. It prints some lines in red
I have to debug a problem with Windows DLLs, but I'm running Linux exclusively,
I'm on a server running a Linux shell. I need to mail a simple
I have a SAM9 based board running embedded linux. I had a JFFS2 file
I am running GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu). I have a specific question pertaining
I hope someone can help me with this :) I am running Arch Linux
I am running some large array processing code (on a Pentium running Linux). The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.