简体   繁体   中英

Replace HTML tags with newline using awk or sed

I have a large file with NO line feeds or carriage returns. The file came from HTML and I have stripped away all of the tags except the that I want to convert to a newline character(/n). What is a quick and easy way to do this using either AWK or SED? I suppose that AWKSED is also an option.

Something like this should work:

sed 's/<[^>]*>/\n/g' file

This means: replace all text starting with < , followed by an unspecified number of characters that are not > , and that ends with > , with a newline character.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM