On Thu, Sep 8, 2011 at 3:12 PM, Mark Galeck (CW) <[email protected]>wrote:
> mgaleck@rh5-017205{382}: ls dir/
> foobar
>
Just FYI:
if foobar is a symlink to a dir then 'ls foobar' and 'ls foobar/' will give
you different results.
That is only to point out that the two are not 100% semantically equivalent
in all contexts:
[stephan@cheyenne:~/tmp]$ ln -s /etc foo
[stephan@cheyenne:~/tmp]$ l foo
lrwxrwxrwx 1 stephan stephan 4 Sep 8 15:16 foo -> /etc
[stephan@cheyenne:~/tmp]$ l foo/
total 1344
drwxr-xr-x 157 root root 12288 Sep 8 10:12 .
...
Another example of when they're not 100% equivalent is when copying/moving
multiple files and the final target is a directory which does not exist:
[stephan@cheyenne:~/tmp]$ touch a b c
[stephan@cheyenne:~/tmp]$ cp a b c d
cp: target `d' is not a directory
[stephan@cheyenne:~/tmp]$ cp a b c d/
cp: accessing `d/': Not a directory
When copying _single_ files this way, the former can be semantically broken
if the target dir does not exist (because a _file_ will be created with the
target name), a problem one can work around by always adding the trailing
slash to the target:
[stephan@cheyenne:~/tmp]$ cp a y
[stephan@cheyenne:~/tmp]$ cp a z/
cp: cannot create regular file `z/': Is a directory
by adding the slash, you cause the copy/mv to fail if the dir doesn't exist
(i often find this useful, and have gotten in the habit of always adding /.
to the end of cp/mv/scp paths).
--
----- stephan beal
http://wanderinghorse.net/home/stephan/
_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make