How can you find and replace text in a file using the Windows command-line environment?

A lot of the answers here helped point me in the right direction, however none were suitable for me, so I am posting my solution. I have Windows 7, which comes with PowerShell built-in. Here is the script I used to find/replace all instances of text in a file: powershell -Command “(gc myFile.txt) -replace ‘foo’, … Read more

How do I set a variable to the output of a command in Bash?

In addition to backticks `command`, command substitution can be done with $(command) or “$(command)”, which I find easier to read, and allows for nesting. OUTPUT=$(ls -1) echo “${OUTPUT}” MULTILINE=$(ls \ -1) echo “${MULTILINE}” Quoting (“) does matter to preserve multi-line variable values; it is optional on the right-hand side of an assignment, as word splitting … Read more

Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)

The problem is that Xcode Command-line Tools needs to be updated. Solution #1 Go back to your terminal and enter: xcode-select –install You’ll then receive the following output: xcode-select: note: install requested for command line developer tools You will then be prompted in a window to update Xcode Command Line tools. (which may take a … Read more