How can I get the path that the file is in? For example, my script is running in ~/Desktop/Projects/Shell but it doesn't know that. How can I get it to know that? Like DIR = DIR_IM_IN?
Plazmotech
0
Newbie Poster
Recommended Answers
Jump to Post
pwd
will print the working directory. Or,${PWD}
Jump to PostShamelessly stolen from the interwebs.
pushd `dirname $0` > /dev/null SCRIPTPATH=`pwd -P` popd > /dev/null
Jump to PostWhat does see man bash /^ *0 mean?
open bash's man page, and type /^ *0
/ is to search
^ *0 is line which begins with space(s) and a zero.Shamelessly stolen from the interwebs.
1. pushddirname $0
> /dev/null
2. SCRIPTPATH=pwd -P
…
All 9 Replies
L7Sqr
227
Practically a Master Poster
Watael
4
Junior Poster
Plazmotech
0
Newbie Poster
Plazmotech
0
Newbie Poster
L7Sqr
227
Practically a Master Poster
Watael
4
Junior Poster
Plazmotech
0
Newbie Poster
Plazmotech
0
Newbie Poster
L7Sqr
227
Practically a Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.