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
245
votes
8 answers

Convert file path to a file URI?

Does the .NET Framework have any methods for converting a path (e.g. "C:\whatever.txt") into a file URI (e.g. "file:///C:/whatever.txt")? The System.Uri class has the reverse (from a file URI to absolute path), but nothing as far as I can find for…
Tinister
  • 11,097
  • 6
  • 35
  • 36
244
votes
11 answers

Python list directory, subdirectory, and files

I'm trying to make a script to list all directories, subdirectories, and files in a given directory. I tried this: import sys, os root = "/home/patate/directory/" path = os.path.join(root, "targetdirectory") for r, d, f in os.walk(path): for…
thomytheyon
  • 2,489
  • 2
  • 16
  • 6
238
votes
8 answers

Java: Path vs File

For new applications written in Java 7, is there any reason to use a java.io.File object any more or can we consider it deprecated? I believe a java.nio.file.Path can do everything a java.io.File can do and more.
dogbane
  • 266,786
  • 75
  • 396
  • 414
236
votes
15 answers

Environment variable is too large on Windows 10

I have recently upgraded to Windows 10 from Windows 8.1. Now I wanted to set an environment variable for my new installation of Apache Maven. Each time I created the user variable, things were fine. However, I also need to create the system variable…
olasammy
  • 6,676
  • 4
  • 26
  • 32
233
votes
26 answers

How to retrieve absolute path given relative

Is there a command to retrieve the absolute path given a relative path? For example I want $line to contain the absolute path of each file in dir ./etc/ find ./ -type f | while read line; do echo $line done
nubme
  • 2,857
  • 8
  • 29
  • 25
233
votes
13 answers

How do I get the path of the current executed file in Python?

Is there a universal approach in Python, to find out the path to the file that is currently executing? Failing approaches path = os.path.abspath(os.path.dirname(sys.argv[0])) This does not work if you are running from another Python script in…
sorin
  • 161,544
  • 178
  • 535
  • 806
231
votes
13 answers

Setting PATH environment variable in OSX permanently

I have read several answers on how to set environment variables on OSX permanently. First, I tried this, How to permanently set $PATH on Linux/Unix but I had an error message saying no such file and directory, so I thought I could try …
patti_jane
  • 3,293
  • 5
  • 21
  • 26
226
votes
29 answers

Android SDK manager won't open

So I installed the android sdk for Windows: http://developer.android.com/sdk/index.html (the installation link) And ran into the path variable problem. So I fixed that by changing "PATH" in enviroment variables to include where my java.exe file…
JDS
  • 16,388
  • 47
  • 161
  • 224
225
votes
3 answers

How to add a set path only for that batch file executing?

Basically, I know I can go through my control panel and modify the path variable. But, I'm wondering if there is a way to through batch programming have a temporary path included? That way it is only used during that batch file execution. I don't…
michael
  • 14,844
  • 28
  • 89
  • 177
220
votes
3 answers

os.makedirs doesn't understand "~" in my path

I have a little problem with ~ in my paths. This code example creates some directories called ~/some_dir and do not understand that I wanted to create some_dir in my home directory. my_dir = "~/some_dir" if not os.path.exists(my_dir): …
Johan
  • 20,067
  • 28
  • 92
  • 110
216
votes
10 answers

How to refer to relative paths of resources when working with a code repository

We are working with a code repository which is deployed to both Windows and Linux - sometimes in different directories. How should one of the modules inside the project refer to one of the non-Python resources in the project (CSV files, etc.)? If…
olamundo
  • 23,991
  • 34
  • 108
  • 149
215
votes
12 answers

Multiple path names for a same component in React Router

I am using the same component for three different routes: Is there anyway to combine it, to…
Chetan Garg
  • 2,167
  • 2
  • 9
  • 3
212
votes
31 answers

__FILE__ macro shows full path

The standard predefined macro __FILE__ available in C shows the full path to the file. Is there any way to shorten the path and get just the filename? I mean instead of /full/path/to/file.c I see to/file.c or file.c
mahmood
  • 23,197
  • 49
  • 147
  • 242
212
votes
9 answers

Get real path from URI, Android KitKat new storage access framework

Before the new gallery access in Android 4.4 (KitKat) I got my real path on the SD card with this method: public String getPath(Uri uri) { String[] projection = { MediaStore.Images.Media.DATA }; Cursor cursor = managedQuery(uri, projection,…
Álvaro
  • 2,872
  • 4
  • 20
  • 25
211
votes
14 answers

Open file in a relative location in Python

Suppose my python code is executed a directory called main and the application needs to access main/2091/data.txt. how should I use open(location)? what should the parameter location be? I found that below simple code will work.. does it have any…
user845459