LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Full Path Name (https://www.linuxquestions.org/questions/linux-newbie-8/full-path-name-850525/)

Juve IT 12-15-2010 07:03 PM

Full Path Name
 
What is a full path name?

andrewthomas 12-15-2010 07:19 PM

As opposed to the relative path name, from the current directory, the full path name is the path from /.

coexistance 12-15-2010 07:23 PM

Hello Juve_It!

A full path name is the complete(absolute) location of some file or link.

Example of :
Code:

#!/bin/sh/
less /home/some_user/docs/work/todo.txt
less ~/docs/work/todo.txt

See the "/home/some_user/docs/work/todo.txt" thing?
That's a full path on Linux shell.

See the "~/docs/work/todo.txt" thing?
That's a relative path that does exactly the same as the full path but is easier to type and is dependent of your working directory.

On linux a path usually starts with a slash character '/'.

cheers!

grail 12-15-2010 07:34 PM

Quote:

Originally Posted by coexistance
See the "~/docs/work/todo.txt" thing?
That's a relative path that does exactly the same as the full path but is easier to type and is dependent of your working directory.

Actually that is an aliased path (ie. ~ is an alias for your home directory)

A relative path would be something like:
Code:

rel_path="docs/work/todo.txt"

less $rel_path

Depending on where you execute the script, this will look in the current directory for a directory called 'docs'.

The difference with the above is:
Code:

rel_path="~/docs/work/todo.txt"

less $rel_path

Irrelevant of where you are this will still look in your home path for 'docs' directory.
The real gotcha here is that if someone else executes the script it will look in their home directory

Whereas a full (or absolute) path would be:
Code:

abs_path="/home/some_user/docs/work/todo.txt"

less $rel_path

This will work no matter who calls it or where it is called from (assuming of course you have the permissions to the directory and file)

coexistance 12-16-2010 01:18 AM

Ah! A relative path is made with variables!
thanks for pointing it out grail.

And sorry for the original poster.
cheers!

chrism01 12-16-2010 08:14 PM

Actually, the '~' thing is only for someone's home dir (that's a fixed convention, not a variable). A relative path in general means not starting at root ie '/', so for eaxmple

../../some/dir

is a relative path; in this case, go up 2 dirs, then down into some/dir.

onebuck 12-16-2010 08:22 PM

Hi,

Welcome to LQ!

Quote:

Originally Posted by Juve IT (Post 4192954)
What is a full path name?

Rute Tutorial & Exposition is a good tutorial and you will learn a lot.

Just a few more links to aid you to gaining some understanding. Sure some may seem beyond a newbie but you must start somewhere;



Linux Documentation Project
Linux Command Guide
Utimate Linux Newbie Guide
LinuxSelfHelp
Getting Started with Linux
Bash Beginners Guide
Bash Reference Manual
Advanced Bash-Scripting Guide
Linux Home Networking



The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!

:hattip:


All times are GMT -5. The time now is 11:19 PM.