If you use the -i
option you need to provide an extension for your backups.
If you have:
File1.txt File2.cfg
The command (note the lack of space between -i
and ''
and the -e
to make it work on new versions of Mac and on GNU):
sed -i'.original' -e 's/old_link/new_link/g' *
Create 2 backup files like:
File1.txt.original File2.cfg.original
There is no portable way to avoid making backup files because it is impossible to find a mix of sed commands that works on all cases:
sed -i -e ...
– does not work on OS X as it creates-e
backupssed -i'' -e ...
– does not work on OS X 10.6 but works on 10.9+sed -i '' -e ...
– not working on GNU
Note Given that there isn’t a sed command working on all platforms, you can try to use another command to achieve the same result.
E.g., perl -i -pe's/old_link/new_link/g' *
Related Posts:
- Installing Homebrew on OS X
- “sed” command in bash
- mvn command not found in OSX Mavrerick
- Recursively find all files that match a certain pattern
- mvn command not found in OSX Mavrerick
- Open an .html file with default browser using Bash on Mac
- -bash: export: `=’: not a valid identifier
- RE error: illegal byte sequence on Mac OS X
- psql: command not found Mac
- Why does cURL return error “(23) Failed writing body”?
- Pipe to/from the clipboard in a Bash script
- Error when using ‘sed’ with ‘find’ command on OS X: “invalid command code .”
- How do I deal with a filename that starts with the hyphen (-) character?
- Bash: No such file or directory?
- How to create a file in Linux from terminal window? [closed]
- Enable OpenMP support in clang in Mac OS X (sierra & Mojave)
- How can I run python in terminal on a mac?
- Where to place $PATH variable assertions in zsh?
- Enable OpenMP support in clang in Mac OS X (sierra & Mojave)
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’
- No “Proceed Anyway” option on NET::ERR_CERT_INVALID in Chrome on MacOS
- Why do you need to put #!/bin/bash at the beginning of a script file?
- “Couldn’t find a file descriptor referring to the console” on Ubuntu bash on Windows
- Xcode is not currently available from the Software Update server
- How to grep for case insensitive string in a file?
- How to view / open a calculator in mac OS X?
- Xcode is not currently available from the Software Update server
- How to uninstall Python 2.7 on a Mac OS X 10.6.4?
- Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch
- VirtualBox NS_ERROR_FAILURE (0x80004005) macOS
- Updating Python on Mac
- How do I upgrade to Python 3.6 with conda?
- You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory
- gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now
- pip or pip3 to install packages for Python 3?
- You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user)
- How to change default Python version?
- SocketException: Address already in use MONGODB
- OS X: equivalent of Linux’s wget
- Terminal error: zsh: permission denied: ./startup.sh
- Failed to attach the USB device SEGGER J-Link [0100] to the virtual machine WINDOWS 7
- You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user)
- ImportError: No module named sklearn (Python)
- What’s a good hex editor/viewer for the Mac?
- Pass a password to ssh in pure bash
- Where to find Application Loader app in Mac?
- -bash: syntax error near unexpected token `newline’ for display command
- OS X: equivalent of Linux’s wget
- How to switch Python versions in Terminal?
- How do I use grep to search the current directory for all files having the a string “hello” yet display only .h and .cc files?
- How to change default Python version?
- Brew install docker does not include docker engine?
- What version of Python is on my Mac?
- brew install mysql on macOS
- How do you update Xcode on OSX to the latest version?
- What languages are Windows, Mac OS X and Linux written in?
- Mongod complains that there is no /data/db folder
- How can I open the Atom editor from the command line in OS X?
- How to uninstall Docker completely from a Mac?
- Explaining the ‘find -mtime’ command
- How to easily install and uninstall docker on MacOs
- How does “cat << EOF" work in bash?
- How to install wget in macOS?
- Pseudo-terminal will not be allocated because stdin is not a terminal
- Cannot use mkdir in home directory: permission denied (Linux Lubuntu)
- Maven Install on Mac OS X
- dyld: Library not loaded … Reason: Image not found
- How to install Java 8 on Mac
- editing PATH variable on mac
- Find (and kill) process locking port 3000 on Mac
- How to remove double-quotes in jq output for parsing json files in bash?
- OS X Framework Library not loaded: ‘Image not found’
- How to update Ruby with Homebrew?
- Upgrade Node.js to the latest version on Mac OS
- How can I kill a process by name instead of PID, on Linux?
- Extract file basename without path and extension in bash
- Given two directory trees, how can I find out which files differ by content?
- mv: cannot stat error : No such file or directory error
- Install Visual Studio 2015 on mac
- How to change the output color of echo in Linux
- Vim Can’t Save File (E212)
- Change default title in mac terminal window
- How to remove the quotes when reading a variable in jq in shell?
- Installing cgdb on a mac os x
- How do I update the password for Git?
- How can I install a previous version of Python 3 in macOS using homebrew?
- “code .” Not working in Command Line for Visual Studio Code on OSX/Mac
- Pseudo-terminal will not be allocated because stdin is not a terminal
- What is the “Illegal Instruction: 4” error and why does “-mmacosx-version-min=10.x” fix it?
- How would I get a cron job to run every 30 minutes?
- How can I Remove .DS_Store files from a Git repository?
- ./configure : /bin/sh^M : bad interpreter
- standard_init_linux.go:178: exec user process caused “exec format error”
- Trying to use bash on Windows and got no installed distributions message
- Shared folder between MacOSX and Windows on Virtual Box
- VirtualBox: mount.vboxsf: mounting failed with the error: No such device
- Installing GCC on macOS Catalina
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- gdb fails with “Unable to find Mach task port for process-id” error
- -bash: fork: Cannot allocate memory