windows equivalent of ./ (current directory)
A period denotes the current directory in Windows.
For your example you would use the following:
c:\> cd c:\windows
c:\Windows> .\System32\ipconfig.exe
Alternately, you could forego the .\ and do it like this:
c:\Windows> System32\ipconfig.exe
Windows shell command to get the full path to the current directory?
Use cd
with no arguments if you're using the shell directly, or %cd%
if you want to use it in a batch file (it behaves like an environment variable).
Windows equivalent to UNIX pwd
This prints it in the console:
echo %cd%
or paste this command in CMD, then you'll have pwd
:
(echo @echo off
echo echo ^%cd^%) > C:\WINDOWS\pwd.bat
What is the current directory in a batch file?
From within your batch file:
%cd%
refers to the current working directory (variable)%~dp0
refers to the full path to the batch file's directory (static)%~dpnx0
and%~f0
both refer to the full path to the batch directory and file name (static).
See also: What does %~dp0 mean, and how does it work?
Git for Windows equivalent for open current directory command
Lets say I have a file called index.html and from the command line I want to use a command that would pull up this file up in sublime text which is my default text editor. How would I do that?
Simply define an alias (if you are in a CMD session, started with git-cmd.bat
.
In Windows, that would be:
doskey sbt=start "Sublime Text 3" "C:\path\to\Sublime_Text_x64\sublime_text.exe" $*
In a git bash shell:
alias sbt='"/c/path/to/SublimeText/sublime_text.exe"'
Then type sbt yourFile
, and it will open directly in Sublime Text.
What are . and .. in Windows' directory?
"." is the current directory.
".." is the parent directory.
This is the same as Unix systems. From your output it looks like Windows is treating them as files.
In the past I've used the "." to make sure that the command (what ever it might be) finds the file in the current directory. The following two statements should be identical:
run some.exe
run ./some.exe
but if you have some weird search rules that looks on the PATH or in C:\Windows first (for example) then they aren't.
I've found these statements:
- Use a period as a directory component in a path to represent the current directory, for example ".\temp.txt". For more information, see Paths.
- Use two consecutive periods (..) as a directory component in a path to represent the parent of the current directory, for example "..\temp.txt". For more information, see Paths.
on the MSDN page on Naming Files, Paths, and Namespaces but there's no explanation of what they actually are.
The Wikipedia page on Path as a little more information, but again doesn't explain how these are actually stored.
Mount current directory as a volume in Docker on Windows 10
In Windows Command Line (cmd
), you can mount the current directory like so:
docker run --rm -it -v %cd%:/usr/src/project gcc:4.9
In PowerShell, you use ${PWD}
, which gives you the current directory:
docker run --rm -it -v ${PWD}:/usr/src/project gcc:4.9
On Linux:
docker run --rm -it -v $(pwd):/usr/src/project gcc:4.9
Cross Platform
The following options will work on both PowerShell and on Linux (at least Ubuntu):
docker run --rm -it -v ${PWD}:/usr/src/project gcc:4.9
docker run --rm -it -v $(pwd):/usr/src/project gcc:4.9
Related Topics
How to Grep While Avoiding 'Too Many Arguments'
Shell Command to Update Pom File from a Variable
Provide Password Using Shell Script
Linux Assembler Error "Impossible Constraint in 'Asm'"
Compile Linux Kernel (2.6) Module Including Non Kernel Headers
Gdb: Lx-Symbols Undefined Command
Getting Current Working Directory Within Kernel Code
How to Compare 2 Lists of Ranges in Bash
Is It Safe to Use "Ls" in for Loop in Bash
How to Mount Google Bucket as Local Disk on Linux Instance with Full Access Rights
How Can Linux Ptrace Be Unsafe or Contain a Race Condition
Error Marking Master: Timed Out Waiting for the Condition [Kubernetes]
Difference Between Kernel, Kernel-Thread and User-Thread
Linux Sort Doesn't Work with Negative Float Numbers
How to Capture All the Commands Typed in Unix/Linux by Any User
Top Command First Iteration Always Returns the Same Result