Strategies for making changes that affect a large number of files
emacs:
- recursive editing (C-r, C-M-c)
- find-grep-dired
- ibuffer (Used to save large number of buffers at once)
- dired-do-query-replace-regexp (find-replace across marked files in dired buffer)
shell:
- grep -rIl 'pattern' * > files_to_op_on (that's a capital i and a lowercase L)
- grep option -r: recurse
- grep option -I: (capital i) exclude binary files
- grep option -l: (lowercase L) Show only filenames with matching content, no other output.
- grep option -h: don't include filename in the match line.
- cat files_to_op_on | xargs sed -i backup_extension 's/old/new/g' #Note that bsd sed required a backup extension with the -i argument.
- cat files_to_op_on | xargs p4 edit
Watch out for symlinks! If you get them in your changelist, p4 won't accept submit, in which case you'll need to delete them via p4 change.
p4 submit > /dev/nullworks well to just get the errors.
The general pattern of:
grep -rI 'something' * | sort -ucan show you the variations you'll need to fix. If you want to get rid of leading whitespace in your results, try piping through:
sed -E -e 's/^[[:space:]]+//'