Linux: how to replace contents of file


Example we have many html files with content like:

line1<br>line2<br>
[root@tutorialspots ok]# ls
backup_type33_okru0.html     backup_type4_okru32001.html
backup_type33_okru1001.html  backup_type4_okru32501.html
backup_type33_okru1501.html  backup_type4_okru33001.html
backup_type33_okru2001.html  backup_type4_okru33501.html
backup_type33_okru2501.html  backup_type4_okru34001.html
backup_type33_okru3001.html  backup_type4_okru34501.html
backup_type33_okru3501.html  backup_type4_okru35001.html
backup_type33_okru4001.html  backup_type4_okru3501.html
backup_type33_okru4501.html  backup_type4_okru35501.html
backup_type33_okru5001.html  backup_type4_okru36001.html
backup_type33_okru501.html   backup_type4_okru36501.html
backup_type33_okru5501.html  backup_type4_okru37001.html
backup_type33_okru6001.html  backup_type4_okru37501.html
backup_type33_okru6501.html  backup_type4_okru38001.html
backup_type33_okru7001.html  backup_type4_okru38501.html
backup_type33_okru7501.html  backup_type4_okru39001.html
backup_type33_okru8001.html  backup_type4_okru39501.html
backup_type33_okru8501.html  backup_type4_okru40001.html
backup_type4_okru0.html      backup_type4_okru4001.html
backup_type4_okru10001.html  backup_type4_okru40501.html
backup_type4_okru1001.html   backup_type4_okru41001.html
backup_type4_okru10501.html  backup_type4_okru41501.html
backup_type4_okru11001.html  backup_type4_okru42001.html
backup_type4_okru11501.html  backup_type4_okru42501.html
backup_type4_okru12001.html  backup_type4_okru43001.html
backup_type4_okru12501.html  backup_type4_okru43501.html
backup_type4_okru13001.html  backup_type4_okru44001.html
backup_type4_okru13501.html  backup_type4_okru44501.html
backup_type4_okru14001.html  backup_type4_okru45001.html
backup_type4_okru14501.html  backup_type4_okru4501.html
backup_type4_okru15001.html  backup_type4_okru45501.html
backup_type4_okru1501.html   backup_type4_okru46001.html
backup_type4_okru15501.html  backup_type4_okru46501.html
backup_type4_okru16001.html  backup_type4_okru47001.html
backup_type4_okru16501.html  backup_type4_okru47501.html
backup_type4_okru17001.html  backup_type4_okru48001.html
backup_type4_okru17501.html  backup_type4_okru48501.html
backup_type4_okru18001.html  backup_type4_okru49001.html
backup_type4_okru18501.html  backup_type4_okru49501.html
backup_type4_okru19001.html  backup_type4_okru50001.html
backup_type4_okru19501.html  backup_type4_okru5001.html
backup_type4_okru20001.html  backup_type4_okru501.html
backup_type4_okru2001.html   backup_type4_okru50501.html
backup_type4_okru20501.html  backup_type4_okru51001.html
backup_type4_okru21001.html  backup_type4_okru51501.html
backup_type4_okru21501.html  backup_type4_okru52001.html
backup_type4_okru22001.html  backup_type4_okru52501.html
backup_type4_okru22501.html  backup_type4_okru53001.html
backup_type4_okru23001.html  backup_type4_okru53501.html
backup_type4_okru23501.html  backup_type4_okru54001.html
backup_type4_okru24001.html  backup_type4_okru54501.html
backup_type4_okru24501.html  backup_type4_okru55001.html
backup_type4_okru25001.html  backup_type4_okru5501.html
backup_type4_okru2501.html   backup_type4_okru55501.html
backup_type4_okru25501.html  backup_type4_okru56001.html
backup_type4_okru26001.html  backup_type4_okru56501.html
backup_type4_okru26501.html  backup_type4_okru57001.html
backup_type4_okru27001.html  backup_type4_okru57501.html
backup_type4_okru27501.html  backup_type4_okru6001.html
backup_type4_okru28001.html  backup_type4_okru6501.html
backup_type4_okru28501.html  backup_type4_okru7001.html
backup_type4_okru29001.html  backup_type4_okru7501.html
backup_type4_okru29501.html  backup_type4_okru8001.html
backup_type4_okru30001.html  backup_type4_okru8501.html
backup_type4_okru3001.html   backup_type4_okru9001.html
backup_type4_okru30501.html  backup_type4_okru9501.html
backup_type4_okru31001.html  backup_type4_okru31501.html

How to replace <br> to new line of all html files with a command line in Linux

sed -i 's/<br>/\n/g' *.html

Leave a Reply