Questions tagged [path]

The general form of a file or directory name that specifies a unique location in a file system. In many Linux and Unix-like OS the PATH (all upper case) variable specifies the directories where executable programs are searched for.

A path represents a unique file system location using the directory tree hierarchy expressed in a string of characters in which path components, separated by a delimiting character, represent each directory. The delimiting character is most commonly a slash /, a backslash \, or a colon :.

A PATH (all upper case, ) in the Linux, UNIX-like operating systems and Windows contains list of directories, where the shell searches through, when a command is executed. The executables are stored in different directories in the OS. On UNIX-like OS the directories are separated by colon, on Windows by semi-colon.

Examples

Simple way to show the $PATH variable is:

echo "$PATH"
printf "%s\n" "$PATH"

A typical PATH looks like:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin

More generally, a path is a sequence of directions that, when followed in order, reach a certain object or location.

In addition to file system paths, there are paths through a tree:

root->left->right->right->left

or, again more generally, a set of attributes on an object.


There might be some other contexts where the term "path" is used to described something non-URI and non-directory related which are not covered by the general description.

One case would be in a context such as in the SCADA software, Ignition, where the term "path" is generally used to refer to tag-path - as Tag is the basic unit in the software, forming a hierarchical system like directory. Typical tag-path in Ignition look like this:

BaseFolder/MyTag

Or, more complexly when tag is not in the BaseFolder but referred from another "Parent" Tag:

BaseFolder/MyAdvanceUDTTag/MyBaseUDTTag/MyTag
19410 questions
173
votes
11 answers

How do I get the path of a process in Unix / Linux?

In a Windows environment there is an API to obtain the path which is running a process. Is there something similar in Unix / Linux? Or is there some other way to do that in these environments?
lsalamon
  • 7,998
  • 6
  • 50
  • 63
173
votes
8 answers

Check if a path represents a file or a folder

I need a valid method to check if a String represents a path for file or a directory. What are valid directory names in Android? As it comes out, folder names can contain '.' chars, so how does system understand whether there's a file or a folder?
Egor
  • 39,695
  • 10
  • 113
  • 130
171
votes
9 answers

How to get folder path from file path with CMD

I need path to the folder that contains cmd file. With %0 I can get the file name. But how to get the folder name? c:\temp\test.cmd >> test.cmd P.S. My current directory != folder of the script.
Mike Chaliy
  • 25,801
  • 18
  • 67
  • 105
171
votes
15 answers

How to get CRON to call in the correct PATHs

I'm trying to get cron to call in the correct PATHs. When I run a Python script from shell the script runs fine as it uses the PATHs set in bashrc but when I use cron all the PATHs are not used from bashrc. Is there a file I can enter the PATHs into…
chrisg
  • 40,337
  • 38
  • 86
  • 107
170
votes
12 answers

How to get the parent dir location

this code is get the templates/blog1/page.html in b.py: path = os.path.join(os.path.dirname(__file__), os.path.join('templates', 'blog1/page.html')) but i want to get the parent dir location: aParent |--a | |---b.py | |---templates …
zjm1126
  • 63,397
  • 81
  • 173
  • 221
165
votes
13 answers

res.sendFile absolute path

If I do a res.sendfile('public/index1.html'); then I get a server console warning express deprecated res.sendfile: Use res.sendFile instead but it works fine on the client side. But when I change it to res.sendFile('public/index1.html'); I…
Kaya Toast
  • 5,267
  • 8
  • 35
  • 59
162
votes
9 answers

How do I find the location of the executable in C?

Is there a way in C/C++ to find the location (full path) of the current executed program? (The problem with argv[0] is that it does not give the full path.)
eran
  • 6,731
  • 6
  • 35
  • 52
162
votes
5 answers

How to modify PATH for Homebrew?

Trying to install ruby 1.9.3, read that I need to install homebrew first. Ran brew doctor, and it's giving me a bunch of warnings. One of which is: Warning: /usr/bin occurs before /usr/local/bin This means that system-provided programs will be…
mrdavidjcole
  • 1,862
  • 3
  • 15
  • 14
160
votes
6 answers

Running python script inside ipython

Is it possible to run a python script (not module) from inside ipython without indicating its path? I tried to set PYTHONPATH but it seems to work only for modules. I would like to execute %run my_script.py without being in the directory…
Tyler Durden
  • 1,611
  • 2
  • 11
  • 3
156
votes
5 answers

Ant path style patterns

What are the rules for Ant path style patterns. The Ant site itself is surprisingly uninformative.
MDK
  • 1,631
  • 3
  • 12
  • 5
155
votes
5 answers

Extract directory from path

In my script I need the directory of the file I am working with. For example, the file="stuff/backup/file.zip". I need a way to get the string "stuff/backup/" from the variable $file.
Matt
  • 2,790
  • 6
  • 24
  • 34
152
votes
18 answers

python: get directory two levels up

Ok...I dont know where module x is, but I know that I need to get the path to the directory two levels up. So, is there a more elegant way to do: import os two_up = os.path.dirname(os.path.dirname(__file__)) Solutions for both Python 2 and 3 are…
jramm
  • 6,415
  • 4
  • 34
  • 73
151
votes
18 answers

Remove redundant paths from $PATH variable

I have defined the same path in the $PATH variable 6 times. I wasn't logging out to check whether it worked. How can I remove the duplicates? The $PATH variable looks like this: echo…
charles hendry
  • 1,710
  • 4
  • 13
  • 18
150
votes
18 answers

Bash script absolute path with OS X

I am trying to obtain the absolute path to the currently running script on OS X. I saw many replies going for readlink -f $0. However since OS X's readlink is the same as BSD's, it just doesn't work (it works with GNU's version). Is there an…
The Mighty Rubber Duck
  • 4,388
  • 5
  • 28
  • 27
149
votes
8 answers

How to add folder to assembly search path at runtime in .NET?

My DLLs are loaded by a third-party application, which we can not customize. My assemblies have to be located in their own folder. I can not put them into GAC (my application has a requirement to be deployed using XCOPY). When the root DLL tries to…
isobretatel
  • 3,812
  • 7
  • 34
  • 49