[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
In the Linux file system is there any difference between "/path/to/dir"
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 28
Thread images: 2
File: linux-terminal[1].png (22 KB, 237x208) Image search: [Google]
linux-terminal[1].png
22 KB, 237x208
In the Linux file system is there any difference between "/path/to/dir" and "/path/to/dir/"?

If so, what?

If they are interchangeable is one more standard?

I've tried Googling but Google doesn't care about /'s.
>>
/path/to/dir would refer to the "dir" directory itself.
/path/to/dir/ actually refers to "/path/to/dir/." which means you're inside the directory.
>>
AU TI SM
>>
>>53822229
I don't follow.

If I cd /root or cd /root/ I still end up in the exact same place. Can you give me an example demonstrating a practical difference between the two?
>>
I think ln cares about the slash when creating links. Most of the time it doesn't matter
>>
>>53822272
>>53822229
To add onto this.
Many commands such as

ls /path/to/dir
ls /path/to/dir/


Would give the same output. In the case of something like rsync however.

rsync -au /path/to/dir /rsync/output/

This would copy the directory "dir" and everything inside of it, making the output /rsync/output/dir/
rsync -au /path/to/dir/ /rsync/output/

This would copy everything inside "dir", but not the directory itself, so all the files inside "dir" would end up in /rsync/output/
>>
>>53822272
Also if you didn't notice, I said
/path/to/dir/ is shorthand for /path/to/dir/.
That period there is special. Do this

mkdir ~/new; ls -a ~/new

You'll notice there will be listings. One is ".." which you probably know means the previous directory, but you'll also see "." which means the current directory.
>>
As others have pointed
/path/to/dir
refers to the node dir, whereas
/path/to/dir/
refers to all nodes inside the dir node.
>>
in simple words:
/dir refers to folder
/dir/ refers to everything inside folder
>>
>>53822304
>>53822340
>>53822344
Cheers, thank you /g/
>>
Theres no effective difference between the two as they are just paths.

What 'dir' is isnt knowable from the first path: it could be a dir, or it could be a file called dir, or a link - hard or soft - etc.

In the second path the user is asserting that dir is a directory for sure.

Either way, it isnt until dir is actually accessed that the nature of dir itself will be resolved.

>>53822304
This is good

Also thank you everyone for not saying 'folders'
>>
>>53822304
>>53822382
right
it depends on the program

>>53822367
absolutely wrong
>>
File: 1459549249881.png (52 KB, 200x200) Image search: [Google]
1459549249881.png
52 KB, 200x200
>>53822386
t. autism
>>
>>53822386
program? I think you meant application.
>>
>>53822408
applications are programs
>>
>>53822408
app*
>>
>>53822429
does your app run in the cloud?
>>
>>53822439
yes my apple iCloud
>>
>>53822408

Think you mean app.
>>
Wow, OP isn't a faggot and actually asked a good question. Cheers m8.
>>
>>53822367
Folders != directories

A directory is a filesystem object.
A folder can be something that contains addressable paths, but contained in a file. A zip file, for instance
>>
>>53822704
practically the same stop your autismposting
>>
>>53822704

Wow I wish there was a way to cyberbully you. What does that have to do with all this?
>>
>>53822704
Citation needed!
>>
>>53823414
From Raymond Chen
https://blogs.msdn.microsoft.com/oldnewthing/20110216-00/?p=11473/

>>53823398
>>53822890
You two children can kiss my sweet grown up ass
>>
If you concatenate a filename in a sloppy way to the first you might get /path/to/dirfile or /path/to/dir/file while with the second /path/to/dir/file or /path/to/dir//file

The dirfile would give you problems. The double / doesn't do anything problematic.
>>
>>53822272
the only time I've had this matter is with rsync. if you want to transfer a folder with rsync, do "rsync folder1/ folder2/" with the trailing slash. otherwise it doesn't matter. most shells will add it for you
>>
>>53822304
Rsync was the easiest way to show me what practical difference it makes. As far as I know it still somewhat depends on the program.
Thread replies: 28
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.