xmlファイルへのパスを含むtxtファイルがあります。テキストファイルからパスを読み取り、各xmlファイルに存在するタブの数を出力したいのですが、これを行うにはどうすればよいですか?
これが私がしたことです
パス付きのtxtファイル
/home/user/Desktop/softwares/firefox/searchplugins/bing.xml
/home/user/Desktop/softwares/firefox/searchplugins/eBay.xml
/home/user/Desktop/softwares/firefox/searchplugins/answers.xml
/home/user/Desktop/softwares/firefox/searchplugins/wikipedia.xml
/home/user/Desktop/softwares/firefox/blocklist.xml
各ファイルのタブをカウントするコード
コード:
#!/bin/sh
#
FILEPATH=/home/user/Desktop/softwares/firefox/*.xml
for file in $FILEPATH; do
tabs=$(tr -cd '\t' < $file | wc -c);
echo "$tabs tabs in file $file" >> /home/user/Desktop/output.txt
done
echo "Done!"