linux - Extract string from HTML text file and use it to rename a file -
i several html files contain tag name want utilize actual file name. illustration html file:
<div class="top">somethingfile</div> <a href="../files/15d705df3.txt"/>
output: want somethingfile tag name of 15d705df3.txt
15d705df3.txt --> somethingfile.txt
i have 800+ text , html files same format rename. have been attempting working awk, sed, , grep. unfortunately @ loss , stuck on creating initial 2 variables , using these rename file.
loop on files, utilize sed
extract new name of file , rename file.
for file in * name=$(sed -n 's|.*<div class="top">\(.*\)</div>|\1|p' "$file") mv "$file" "$name.txt" done
linux shell sed awk grep
No comments:
Post a Comment