To change your default directory (in Windows 10, as of Dec 2019)
- Go to: C:\Users\<name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Windows System
- Right-click Command Prompt > Properties
- Shortcut tab > change "Start in" to any bash path
If you have pinned Command Prompt to your taskbar, you'll need to remove it and then re-pin it to see the change.
AppData is a hidden folder.
An application window is open, but is off the screen so I can't see it.
Shift+Right-click window in Task Bar > select Move > move the cursor around until you can see the window
Windows command line tools, for those who miss Linux.
To copy from the command line:
- Drag and drop with mouse to highlight text
- Right-click mouse
The text has been copied to your clipboard.
To copy to the command line:
- Copy to clip board like normal
- Right-click mouse in command line where you want the text inserted
Display the first screen-worth of a file:
Click "enter" to see one more line.
Click "space" to see one more screen-worth.
Click "q" for Quit to exit.
Skip the first 10 lines of the file:
more +10 fileName
List all the paths where this program is found.
Useful for figuring out why the old version of python is still running.
Findstr is a search tool for Windows similar to grep in Linux.
By default, findstr interprets the search string as a regular expression.
Search results of "dir" for a string
dir | findstr "notes"
Search a file for a string:
Outputs each line containing that string.
findstr "notes" fileName
Display line number of each match:
findstr /n "notes" fileName
Search for multiple strings using "space" delimiter:
To search for strings containing spaces, do one of the following:
findstr "notes other" fileName
- use "/c: string" parameter
- use "." instead of " "
List files in directory that contain the string:
findstr /M "notes" directoryName
List lines in files in directory that contain the string:
findstr "notes" directoryName
Search directory recursively:
Displays path to file with each match.
findstr /s "notes" directoryName
Parameters can be specified individually, or all together.
These commands are the same, specifying recursive directory search, case insensitive, display just file name, and don't search files with strange characters.
findstr /s /i /m /p "string" * findstr /simp "string" *
/a: colorAttribute Specifies color attributes with two hexadecimal digits
/b Matches pattern only to beginning of line
/c: string Runs literal match search on for "string"
/d: dirList Searches this comma-delimited list of directories
/e Matches pattern only to end of line
/f: fileName Processes files listed in this file
/g: fileName Gets search strings from this file
/i Case-insensitive search
/l Matches search string literally (slash-letter-ell)
/m Prints only the file name of each file with a match
/n Prints the line number with each match
/o Prints seek-offset before each matching line
/offline Processes files with offline attribute sets
/p Skips files with non-printable characters
/r Matches search string as a regular expression (default, unless you use /l)
/s Search directory recursively
/v Prints only lines can do not match
/x Matches entire line only
period (.) matches any single character
asterisk (*) means the previous character/set/etc can be matched 0 or more times
So "A.*C" will match "AC", "ABC", "A483hskduf89C", etc