Skip to content

Instantly share code, notes, and snippets.

@lwl5219
Last active April 8, 2019 10:13
Show Gist options
  • Save lwl5219/c07848be6761da100e3bcb1f803656be to your computer and use it in GitHub Desktop.
Save lwl5219/c07848be6761da100e3bcb1f803656be to your computer and use it in GitHub Desktop.
[Useful bash commands] #cmd
##### Use the contents of a file to replace a string using SED
# You can use the `r` command.
# Reference: https://stackoverflow.com/a/6790967/1673077
# Example: use the contents of fileA.txt to replace the line that contains 'china' in fileB.txt
sed -i -e '/china/{r fileA.txt' -e 'd' -e '}' fileB.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment