When you press enter, the shell first processes any redirections, in this case > {}
. That happens before the shell creates the process for find
since it needs to connect the output of the find
process to {}
. Which means you should find a file {}
in the current folder.
I think you're better off with a loop in this case:
find . -type f -print0 | while IFS= read -r -d $'\0' file
do
awk ... "$file" > "$file"
done
but there is a catch: Again, the shell will first do the redirection. That means it will create an empty $file
as output for awk
and then start awk
which will then commence to read said empty file. A more simple way to achieve the same thing would be echo -n > "$file"
.
So you really need to write to a temporary file and then rename:
find . -type f -print0 | while IFS= read -r -d $'\0' file
do
awk ... "$file" > "$file.tmp" && mv "$file.tmp" "$file"
done
And make sure you have a backup of everything before you run the command because it might go horribly wrong. For example, if you have a hidden folder from your version control, find
will go in there and awk
will then destroy a few important bits.
PS: If you use an IDE, enable regular expressions and search for #pragma mark -\n#pragma mark Getters
. Now you can replace the two lines with a single one and your IDE will make 95% sure that the string isn't replaced in places where you don't want it to happen.