Does using ./ in paths make sense with common Unix tools?2019 Community Moderator ElectionWhy cat, grep and other commands can't understand files starting with minus sign?What does the ./ mean (dot slash) in linux?History of UNIX not including current directory in $PATHAdding paths to PATH using a multi-line syntaxMake problem with includesbroken pipe error with popen and JS ffiWhy isn't there any shell command to create files?Is it possible to drop all write privileges in a shell for the current userBash pattern to match directories whose names begin with a dot (period), by being “explicit”, instead of using “shopt -s dotglob”?How to fetch one file from two paths in unix?How to make sense of non-interactive login shell?Should we use UTF-8 characters like ⏰ in bash/shell script?Using unusual paths with commands

Freedom of speech and where it applies

Bob has never been a M before

Is there a problem with hiding "forgot password" until it's needed?

Is there enough fresh water in the world to eradicate the drinking water crisis?

Invariance of results when scaling explanatory variables in logistic regression, is there a proof?

Adding empty element to declared container without declaring type of element

Why does this part of the Space Shuttle launch pad seem to be floating in air?

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

How to deal with or prevent idle in the test team?

Are Warlocks Arcane or Divine?

Perfect riffle shuffles

The One-Electron Universe postulate is true - what simple change can I make to change the whole universe?

Is infinity mathematically observable?

Can the harmonic series explain the origin of the major scale?

Why are all the doors on Ferenginar (the Ferengi home world) far shorter than the average Ferengi?

Can I Retrieve Email Addresses from BCC?

Did US corporations pay demonstrators in the German demonstrations against article 13?

Partial sums of primes

Can a Bard use an arcane focus?

Have I saved too much for retirement so far?

Can I rely on these GitHub repository files?

Is there an wasy way to program in Tikz something like the one in the image?

How to interpret the phrase "t’en a fait voir à toi"?

Visiting the UK as unmarried couple



Does using ./ in paths make sense with common Unix tools?



2019 Community Moderator ElectionWhy cat, grep and other commands can't understand files starting with minus sign?What does the ./ mean (dot slash) in linux?History of UNIX not including current directory in $PATHAdding paths to PATH using a multi-line syntaxMake problem with includesbroken pipe error with popen and JS ffiWhy isn't there any shell command to create files?Is it possible to drop all write privileges in a shell for the current userBash pattern to match directories whose names begin with a dot (period), by being “explicit”, instead of using “shopt -s dotglob”?How to fetch one file from two paths in unix?How to make sense of non-interactive login shell?Should we use UTF-8 characters like ⏰ in bash/shell script?Using unusual paths with commands










1















Throughout the years I've been using ./ in front of absolute paths more and more.
For example:



mv ./file /target/
rm ./something/else

# compared to
mv file /target/
rm something/else


I've seen it in more places around the web, which is probably why I adapted to using it. I can't seem to understand why this is done though, and have been wondering for a while.
Maybe it's a bad habit originating from calling local binaries directly: ./a.out



Is the ./ obsolete in the shell example above? Is there any reason to use ./ in some cases? Does using it possibly make paths more explicit?










share|improve this question



















  • 1





    Here's one reason: Why cat, grep and other commands can't understand files starting with minus sign?

    – steeldriver
    yesterday






  • 1





    Also unix.stackexchange.com/q/397524/117549

    – Jeff Schaller
    yesterday















1















Throughout the years I've been using ./ in front of absolute paths more and more.
For example:



mv ./file /target/
rm ./something/else

# compared to
mv file /target/
rm something/else


I've seen it in more places around the web, which is probably why I adapted to using it. I can't seem to understand why this is done though, and have been wondering for a while.
Maybe it's a bad habit originating from calling local binaries directly: ./a.out



Is the ./ obsolete in the shell example above? Is there any reason to use ./ in some cases? Does using it possibly make paths more explicit?










share|improve this question



















  • 1





    Here's one reason: Why cat, grep and other commands can't understand files starting with minus sign?

    – steeldriver
    yesterday






  • 1





    Also unix.stackexchange.com/q/397524/117549

    – Jeff Schaller
    yesterday













1












1








1


1






Throughout the years I've been using ./ in front of absolute paths more and more.
For example:



mv ./file /target/
rm ./something/else

# compared to
mv file /target/
rm something/else


I've seen it in more places around the web, which is probably why I adapted to using it. I can't seem to understand why this is done though, and have been wondering for a while.
Maybe it's a bad habit originating from calling local binaries directly: ./a.out



Is the ./ obsolete in the shell example above? Is there any reason to use ./ in some cases? Does using it possibly make paths more explicit?










share|improve this question
















Throughout the years I've been using ./ in front of absolute paths more and more.
For example:



mv ./file /target/
rm ./something/else

# compared to
mv file /target/
rm something/else


I've seen it in more places around the web, which is probably why I adapted to using it. I can't seem to understand why this is done though, and have been wondering for a while.
Maybe it's a bad habit originating from calling local binaries directly: ./a.out



Is the ./ obsolete in the shell example above? Is there any reason to use ./ in some cases? Does using it possibly make paths more explicit?







shell path






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday







Tim Visee

















asked yesterday









Tim ViseeTim Visee

1086




1086







  • 1





    Here's one reason: Why cat, grep and other commands can't understand files starting with minus sign?

    – steeldriver
    yesterday






  • 1





    Also unix.stackexchange.com/q/397524/117549

    – Jeff Schaller
    yesterday












  • 1





    Here's one reason: Why cat, grep and other commands can't understand files starting with minus sign?

    – steeldriver
    yesterday






  • 1





    Also unix.stackexchange.com/q/397524/117549

    – Jeff Schaller
    yesterday







1




1





Here's one reason: Why cat, grep and other commands can't understand files starting with minus sign?

– steeldriver
yesterday





Here's one reason: Why cat, grep and other commands can't understand files starting with minus sign?

– steeldriver
yesterday




1




1





Also unix.stackexchange.com/q/397524/117549

– Jeff Schaller
yesterday





Also unix.stackexchange.com/q/397524/117549

– Jeff Schaller
yesterday










1 Answer
1






active

oldest

votes


















2














It's not a bad habit to specify explicitly that something is located in the current directory, especially when that something is a script or program (the alternative in that case would be to have . in your $PATH which is generally considered to be a security risk).



There are situations where you will have ./ at the start of a pathname no matter if you want it or not. For example, the pathnames found by find when searching from . downwards will always be prefixed by ./.



In other situations, a filename may interfere with the options of a utility, as when trying to remove a file called -f with



rm -f


Using



rm ./-f


would solve that (the ./-f would not be taken as an option to rm), as would



rm -- -f


do (the -- signals the end of any command line options).



Also note that shell globs, such as * may expand to files with an initial dash. It is therefore safer to e.g. loop over ./* than over * (unless you use -- to delimit the unknown filename from the options given to utilities).



It is therefore a good idea to use ./ in pathnames, particularly if the pathname is stored in a variable and comes from some source external to the script.






share|improve this answer

























  • So that aggregates into it being obsolete, with the exception for some arguably uncommon situations. Thanks!

    – Tim Visee
    yesterday












  • @TimVisee If you ever do any amount of shell scripting for other people than yourself, you will run into these "uncommon" situations every once in a while, if not often.

    – Kusalananda
    yesterday










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f508336%2fdoes-using-in-paths-make-sense-with-common-unix-tools%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














It's not a bad habit to specify explicitly that something is located in the current directory, especially when that something is a script or program (the alternative in that case would be to have . in your $PATH which is generally considered to be a security risk).



There are situations where you will have ./ at the start of a pathname no matter if you want it or not. For example, the pathnames found by find when searching from . downwards will always be prefixed by ./.



In other situations, a filename may interfere with the options of a utility, as when trying to remove a file called -f with



rm -f


Using



rm ./-f


would solve that (the ./-f would not be taken as an option to rm), as would



rm -- -f


do (the -- signals the end of any command line options).



Also note that shell globs, such as * may expand to files with an initial dash. It is therefore safer to e.g. loop over ./* than over * (unless you use -- to delimit the unknown filename from the options given to utilities).



It is therefore a good idea to use ./ in pathnames, particularly if the pathname is stored in a variable and comes from some source external to the script.






share|improve this answer

























  • So that aggregates into it being obsolete, with the exception for some arguably uncommon situations. Thanks!

    – Tim Visee
    yesterday












  • @TimVisee If you ever do any amount of shell scripting for other people than yourself, you will run into these "uncommon" situations every once in a while, if not often.

    – Kusalananda
    yesterday















2














It's not a bad habit to specify explicitly that something is located in the current directory, especially when that something is a script or program (the alternative in that case would be to have . in your $PATH which is generally considered to be a security risk).



There are situations where you will have ./ at the start of a pathname no matter if you want it or not. For example, the pathnames found by find when searching from . downwards will always be prefixed by ./.



In other situations, a filename may interfere with the options of a utility, as when trying to remove a file called -f with



rm -f


Using



rm ./-f


would solve that (the ./-f would not be taken as an option to rm), as would



rm -- -f


do (the -- signals the end of any command line options).



Also note that shell globs, such as * may expand to files with an initial dash. It is therefore safer to e.g. loop over ./* than over * (unless you use -- to delimit the unknown filename from the options given to utilities).



It is therefore a good idea to use ./ in pathnames, particularly if the pathname is stored in a variable and comes from some source external to the script.






share|improve this answer

























  • So that aggregates into it being obsolete, with the exception for some arguably uncommon situations. Thanks!

    – Tim Visee
    yesterday












  • @TimVisee If you ever do any amount of shell scripting for other people than yourself, you will run into these "uncommon" situations every once in a while, if not often.

    – Kusalananda
    yesterday













2












2








2







It's not a bad habit to specify explicitly that something is located in the current directory, especially when that something is a script or program (the alternative in that case would be to have . in your $PATH which is generally considered to be a security risk).



There are situations where you will have ./ at the start of a pathname no matter if you want it or not. For example, the pathnames found by find when searching from . downwards will always be prefixed by ./.



In other situations, a filename may interfere with the options of a utility, as when trying to remove a file called -f with



rm -f


Using



rm ./-f


would solve that (the ./-f would not be taken as an option to rm), as would



rm -- -f


do (the -- signals the end of any command line options).



Also note that shell globs, such as * may expand to files with an initial dash. It is therefore safer to e.g. loop over ./* than over * (unless you use -- to delimit the unknown filename from the options given to utilities).



It is therefore a good idea to use ./ in pathnames, particularly if the pathname is stored in a variable and comes from some source external to the script.






share|improve this answer















It's not a bad habit to specify explicitly that something is located in the current directory, especially when that something is a script or program (the alternative in that case would be to have . in your $PATH which is generally considered to be a security risk).



There are situations where you will have ./ at the start of a pathname no matter if you want it or not. For example, the pathnames found by find when searching from . downwards will always be prefixed by ./.



In other situations, a filename may interfere with the options of a utility, as when trying to remove a file called -f with



rm -f


Using



rm ./-f


would solve that (the ./-f would not be taken as an option to rm), as would



rm -- -f


do (the -- signals the end of any command line options).



Also note that shell globs, such as * may expand to files with an initial dash. It is therefore safer to e.g. loop over ./* than over * (unless you use -- to delimit the unknown filename from the options given to utilities).



It is therefore a good idea to use ./ in pathnames, particularly if the pathname is stored in a variable and comes from some source external to the script.







share|improve this answer














share|improve this answer



share|improve this answer








edited yesterday

























answered yesterday









KusalanandaKusalananda

137k17258426




137k17258426












  • So that aggregates into it being obsolete, with the exception for some arguably uncommon situations. Thanks!

    – Tim Visee
    yesterday












  • @TimVisee If you ever do any amount of shell scripting for other people than yourself, you will run into these "uncommon" situations every once in a while, if not often.

    – Kusalananda
    yesterday

















  • So that aggregates into it being obsolete, with the exception for some arguably uncommon situations. Thanks!

    – Tim Visee
    yesterday












  • @TimVisee If you ever do any amount of shell scripting for other people than yourself, you will run into these "uncommon" situations every once in a while, if not often.

    – Kusalananda
    yesterday
















So that aggregates into it being obsolete, with the exception for some arguably uncommon situations. Thanks!

– Tim Visee
yesterday






So that aggregates into it being obsolete, with the exception for some arguably uncommon situations. Thanks!

– Tim Visee
yesterday














@TimVisee If you ever do any amount of shell scripting for other people than yourself, you will run into these "uncommon" situations every once in a while, if not often.

– Kusalananda
yesterday





@TimVisee If you ever do any amount of shell scripting for other people than yourself, you will run into these "uncommon" situations every once in a while, if not often.

– Kusalananda
yesterday

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f508336%2fdoes-using-in-paths-make-sense-with-common-unix-tools%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.