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?
- 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
- Xcode is not currently available from the Software Update server
- Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch
- Updating Python on Mac
- How do I upgrade to Python 3.6 with conda?
- gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now
- How to change default Python version?
- SocketException: Address already in use MONGODB
- OS X: equivalent of Linux’s wget
- You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user)
- Pass a password to ssh in pure bash
- Where to find Application Loader app in Mac?
- Brew install docker does not include docker engine?
- What languages are Windows, Mac OS X and Linux written in?
- How can I open the Atom editor from the command line in OS X?
- Explaining the ‘find -mtime’ command
- How to easily install and uninstall docker on MacOs
- Cannot use mkdir in home directory: permission denied (Linux Lubuntu)
- 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?
- Given two directory trees, how can I find out which files differ by content?
- mv: cannot stat error : No such file or directory error
- How to change the output color of echo in Linux
- Vim Can’t Save File (E212)
- How to remove the quotes when reading a variable in jq in shell?
- Installing cgdb on a mac os x
- 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 can I Remove .DS_Store files from a Git repository?
- Trying to use bash on Windows and got no installed distributions message
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- -bash: fork: Cannot allocate memory
- Is there a “goto” statement in bash?
- OS X 10.9.2: checking whether the C compiler works… no
- How to use vim in the terminal?
- Bash script: bad interpreter
- matplotlib: RuntimeError: Python is not installed as a framework
- Arduino IDE is not showing any port macOS
- psql: FATAL: role “postgres” does not exist
- boto3 python 2.7 ImportError: No module named boto3 USER_BASE USER_SITE site packages doesn’t exist
- Python can’t find module NLTK
- Making sure /usr/local/bin is in my $PATH on mac
- What does set -e mean in a bash script?
- Run script on mac prompt “Permission denied”
- Finding text inside a folder using terminal
- Command not found go — on Mac after installing Go
- cannot download, $GOPATH not set
- What is the difference between MacVim and regular Vim?
- gdb debugging in Terminal OS X (10.8.5) with zsh
- Updating php version on mac
- Kill a python process
- “find: paths must precede expression:” How do I specify a recursive search that also finds files in the current directory?
- Copy multiple files from one directory to another from Linux shell
- Unmount the directory which is mounted by sshfs in Mac
- How can I do a recursive find/replace of a string with awk or sed?
- How to use sed to extract substring
- Failed to launch macOS app built in Xcode
- Testing web application on Mac/Safari when I don’t own a Mac
- How to run C program on Mac OS X using Terminal?
- How to completely uninstall Android Studio on Mac?
- How do I write stderr to a file while using “tee” with a pipe?
- How to include file in a bash shell script
- Is there an equivalent of lsusb for OS X
- hat’s a clean way to stop mongod on Mac OS X?
- Does Mac OS X use Linux?
- How to enable Bash in Windows 10 developer preview?
- Open Sublime Text from Terminal in macOS
- bash sh – command not found
- how to update npm on macOS
- How can I sort du -h output by size
- How do I prevent accidental rm -rf /*?
- How do I sleep for a millisecond in bash or ksh
- What’s the best way to check if a volume is mounted in a Bash script?
- What useful things can one add to one’s .bashrc? [closed]
- How to add a timestamp to bash script log?
- Linux command line best practices and tips?
- How to run command as user who has /usr/sbin/nologin as Shell?
- How to get pid of just started process
- How can I fully log all bash scripts actions?
- How to remove invalid characters from filenames?
- zcat/gzcat works in linux, not on osx. general linux/osx compatibility