1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

htmlใ‚ฟใ‚ฐๅ–ใ‚Š(sed) ่‹ฑ่ชž(65)

1
Last updated at Posted at 2020-11-01

htmlใƒ•ใ‚กใ‚คใƒซใ‹ใ‚‰txtใƒ•ใ‚กใ‚คใƒซใ‚’็”Ÿๆˆใ™ใ‚‹ๆ–นๆณ•ใ‚’่ฉฆใ—ใฆใ„ใ‚‹ใ€‚

<ใ“ใฎ้ …ใฏๆ›ธใใ‹ใ‘ใงใ™ใ€‚้ †ๆฌก่ฟฝ่จ˜ใ—ใพใ™ใ€‚>

Delete html tags using sed/grep/awk
https://unix.stackexchange.com/questions/359980/delete-html-tags-using-sed-grep-awk
rmtag.sed

rmtag.sed
sed -e 's/<[^>]*>//g' index.* > indexall.txt

ไธŠ่จ˜ใงใ†ใพใใ„ใ‹ใชใ‹ใฃใŸใฎใฏใ€๏ผ’่กŒใซใพใŸใŒใ‚‹ใ‚ฟใ‚ฐใ€‚
ใ†ใพใๅ–ใ‚Œใชใ‹ใฃใŸใ€‚

ใ“ใ‚“ใชๆ„Ÿใ˜ใ€‚

intexall.txt
	<section id="c188278" class="g-padding-top-5 g-padding-bottom-5
	    ">

ๆ”น่กŒใ‚’ๅ–ใฃใฆใ‹ใ‚‰ๅ‡ฆ็†ใ™ใ‚Œใฐใ†ใพใใ„ใใ‹ใ‚‚ใ€‚

bashใงๅค‰ๆ•ฐๅ†…ใฎๆ”น่กŒใ‚ณใƒผใƒ‰ใ‚’้™คๅŽปใ™ใ‚‹
https://hacknote.jp/archives/12122/

ใ‚ทใ‚งใƒซใ‚นใ‚ฏใƒชใƒ—ใƒˆใงใฎๆ”น่กŒๆ–‡ๅญ—ใฎๅ‰Š้™คใซใƒใƒžใ‚‹
https://hacolab.hatenablog.com/entry/2019/07/29/235312

rmreturn.tr
tr -d '\n' < infile > outfile

ใชใ‚“ใจใ‹ใ†ใพใใ„ใใใ†ใ€‚

bat.sh
#!/bin/sh
# https://unix.stackexchange.com/questions/359980/delete-html-tags-using-sed-grep-awk
# https://hacolab.hatenablog.com/entry/2019/07/29/235312
# https://qiita.com/kaizen_nagoya/items/ad4f75b391ff95e72634

_LISPDIRS=`find . -maxdepth 1 -mindepth 1 -type d`

for _DIRS in ${_LISPDIRS}; do
    echo -e "\n-- ${_DIRS} --"
    cd $_DIRS
    tr -d '\n' < index.* >> /tmp/web/indexall.txt
    cd ../
done
sed -e 's/<[^>]*>//g' /tmp/web/indexall.txt > index.txt

ใ“ใ‚Œใงใฏใพใ ้ง„็›ฎใ ใฃใŸใ€‚

ใ€ใ‚ทใ‚งใƒซใ‚นใ‚ฏใƒชใƒ—ใƒˆใ€‘ใƒ•ใ‚กใ‚คใƒซใ‚„ใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒชใฎๆœ‰็„กใ‚’็ขบ่ชใ™ใ‚‹ๆ–นๆณ•่‰ฒใ€…
https://www.server-memo.net/shellscript/file_check.html

docker/bash
# ./bat.sh
-e 
-- ./www.xxx.com --

./bat.sh: 11: ./bat.sh: cannot open index.*: No such file
# ls 
  index.html  
bat.sh
#!/bin/sh
# https://unix.stackexchange.com/questions/359980/delete-html-tags-using-sed-grep-awk
# https://hacolab.hatenablog.com/entry/2019/07/29/235312
# https://qiita.com/kaizen_nagoya/items/ad4f75b391ff95e72634

_LISPDIRS=`find . -maxdepth 1 -mindepth 1 -type d`

for _DIRS in ${_LISPDIRS}; do
    echo -e "\n-- ${_DIRS} --"
    cd $_DIRS
    if [-e index.* ] then
      tr -d '\n' < index.html >> /tmp/web/indexall.txt
    fi
    cd ../
done
sed -e 's/<[^>]*>//g' /tmp/web/indexall.txt > index.txt
docker/bash
# ./bat.sh
./bat.sh: 13: ./bat.sh: Syntax error: "fi" unexpected (expecting "then")

๏ผœใ“ใฎ่จ˜ไบ‹ใฏๅ€‹ไบบใฎ้ŽๅŽปใฎ็ตŒ้จ“ใซๅŸบใฅใๅ€‹ไบบใฎๆ„Ÿๆƒณใงใ™ใ€‚็พๅœจๆ‰€ๅฑžใ™ใ‚‹็ต„็น”ใ€ๆฅญๅ‹™ใจใฏ้–ขไฟ‚ใŒใ‚ใ‚Šใพใ›ใ‚“ใ€‚๏ผž

ๆœ€ๅพŒใพใงใŠใ‚ˆใฟใ„ใŸใ ใใ‚ใ‚ŠใŒใจใ†ใ”ใ–ใ„ใพใ—ใŸใ€‚

ใ„ใ„ใญใ€€๐Ÿ’šใ€ใƒ•ใ‚ฉใƒญใƒผใ‚’ใŠ้ก˜ใ„ใ—ใพใ™ใ€‚

Thank you very much for reading to the last sentence.

Please press the like icon ๐Ÿ’šใ€€and follow me for your happy life.

'

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?