How it is possible to make a dry run with sed
?
I have this command:
find ./ -type f | xargs sed -i \'s/string1/string2/g\'
Remove the -i
and pipe it to less
to paginate though the results. Alternatively, you can redirect the whole thing to one large file by removing the -i
and appending > dryrun.out
I should note that this script of yours will fail miserably with files that contain spaces in their name or other nefarious characters like newlines or whatnot. A better way to do it would be:
while IFS= read -r -d $'\0' file; do
sed -i 's/string1/string2/g' "$file"
done < <(find ./ -type f -print0)