Skip to content

Instantly share code, notes, and snippets.

@ErvalhouS
Last active August 28, 2017 22:50
Show Gist options
  • Save ErvalhouS/eae903707bdb739f5cf23e3dbdc360ea to your computer and use it in GitHub Desktop.
Save ErvalhouS/eae903707bdb739f5cf23e3dbdc360ea to your computer and use it in GitHub Desktop.
Adding new script line to files contained in folder after regex match
#!/bin/bash
FILES=/path/to/folder/*
for file in $FILES
do
sed -i "/my-complex-regexp-finder/a content-to-add" $file
done
@ErvalhouS
Copy link
Author

The "/a" makes the content to add be a new line on the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment