I am using a shell script to remove the XML tags of a set of files in a folder. This is how my file looks like:
#!/bin/sh find texts -type f -name '*.xml' -exec sh -c ' mkdir -p modified file="$0" sed "s/<[^>]*>//g" "$file" > modified/modified_texts ' {} ';' This is supposed to take all the files(using $file) in the "texts" folder, remove their XML tags and place the files without the XML tags into the file "modified".
The problem is that, instead of taking all the files, it is using just one, and filling the file "modified_texts" with the content of one of the files(without XML tags, that part works).
I don't really understand what I'm doing wrong, so I would appreciate any help.
>>instead of>modified_textsand starts it over from the beginning; so only the last file's content is present in your result.>>to>, though, is to keep> modified/modified_textsthe same, but move it to be at the very end of yourfindcommand. That way instead of reopening the output file every time you runsed, you're opening the output file only once, before you startfindat all, and keeping it open all the way through execution.