Results 1 to 3 of 3
ls mydir
ls ./mydir
ls mydir/
ls ./mydir/
cp xxx mydir
cp xxx ./mydir/
???...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-23-2011 #1Just Joined!
- Join Date
- Oct 2011
- Location
- STL, USA
- Posts
- 8
Do trailing slashes or leading dot-slashes ever matter?
ls mydir
ls ./mydir
ls mydir/
ls ./mydir/
cp xxx mydir
cp xxx ./mydir/
???
- 10-23-2011 #2
AFAIK the only time you need the ./ is when you want to run an executable file in the current directory. ./ tells bash to look in the current directory for a command instead of looking in the path. If you want to copy to the current directory, just use the period, not the slash, as in
Using ls you don't need anything, because the default, with no other modifiers, is to list the contents of the current directory.Code:cp xxx .
- 10-24-2011 #3
They can affect things.
sgosnell discusses the "./" prefix: it can sometimes change a bareword into a relative path, and this is used, for example:
For the case of a trailing slash, this can sometimes matter. A pretty standard example of this is for symlinks to directories:Code:ls # Run the standard "ls" command (probably /bin/ls) ./ls # Run a program called "ls" in the current directory bin/ls # Run a program caled "ls" in the bin/ directory ./bin/ls # Same as above
Code:[alex@niamh ~]$ ls -l test_symlink # List the symlink itself lrwxrwxrwx 1 alex users 4 Oct 23 23:45 test_symlink -> test [alex@niamh ~]$ ls -l test_symlink/ # List the contents of the link target dir total 12 drwxr-xr-x 2 alex users 4096 Oct 22 10:45 c drwxr-xr-x 2 alex users 4096 Oct 22 10:45 perl drwxr-xr-x 2 alex users 4096 Oct 22 10:45 ruby


Reply With Quote
