Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- arquivo="$HOME/teste.txt"
- cat - >> "$arquivo" <<EOF
- http://www.unix.com/shell-programming-scripting/36565-exit-shell-script.html
- http://www.blaa.com.br/ble/bli.htm
- http://www.claa.com.br/cle/cli.htm
- http://www.sub1.dlaa.com/dle/dli.htm
- http://www.sub2.ela.co.uk/ele/eli.htm
- http://flaa.com/fle
- http://suba.glaa.com/gle
- http://sub.sub2.hlaa.com/hle
- http://sub.sub2.ilaa.net.jp/ile
- http://sub2.sub3.jlaa.net/jle
- http://sub.dominio23.com
- EOF
- sed -e 's/\(\([^\/]*\)\/\)\{3\}.*/\2/' -e '/\([a-zA-Z]\)\{3\}$/{s/\(.*\.\)\([a-zA-Z0-9]*\.[a-zA-Z]\{3\}\)$/\2/}' -e '/\([a-zA-Z]\)\{3\}$/!{s/\(.*\.\)\([a-zA-Z0-9]*\.[a-zA-Z]\{2,3\}\.[a-zA-Z]\{2\}\)$/\2/}' $arquivo
- rm $arquivo
- # --------------------------------------------------------------------------------- #
- # Quem não quiser usar apenas uma linha de sed, pode usar as duas linhas abaixo: ;) #
- # cut -d'/' -f3 teste.txt | sed -e '/\.[a-z]\{3\}$/!d' | rev | cut -d'.' -f-2 | rev #
- # cut -d'/' -f3 teste.txt | sed -e '/\.[a-z]\{3\}$/d' | rev | cut -d'.' -f-3 | rev #
- # --------------------------------------------------------------------------------- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement