I would like to rename files with following extensions: .txt, .data, .conf to ".xml"
hello.txt -> hello.xml
To do so, file must also contain the following line: <?xml version="1.0" encoding="UTF-8"?>
This is what I have:
for file in *
do
if [ $(grep -Rc '<?xml version="1.0" encoding="UTF-8"?>' --include ".txt" --include ".data" --include "*.conf") = true ]
then
rename extension to: .xml
fi
done
Any ideas?
-R
option togrep
, so you need recursion, right? I. e., you need to affect matching files in directories below the current one? – Quasímodo Mar 22 '20 at 21:38<?xml version="1.0" encoding="UTF-8"?>
must be in the first line of the file? – Paulo Tomé Mar 22 '20 at 22:22