Showing posts with label Shell Script. Show all posts
Showing posts with label Shell Script. Show all posts

Sunday, July 28, 2019

How to replace a string in multiple files in linux from command line


find ./ -type f -exec sed -i 's/string1/string2/g' {} \;

For global case insensitive:
find ./ -type f -exec sed -i 's/string1/string2/gI' {} \;

Remove the dates from FileName extension


echo 'filename.txt_09232016' | grep -o '^.*\.txt'
Output: filename.txt