Shell: Geração de CVS com shellscript

Origem:
decretos/2006/D05941.html decretos/2012/D07669.html decretos/2012/D07744.html decretos/2017/D09243.html decretos/2017/D09245.html decretos/2017/D09247.html decretos/2017/D09248.html decretos/2017/D09253.html decretos/2017/D09254.html decretos/2017/D09255.html
find decretos/*/D?????.htm[l]|sort -u|while read a; do echo -n $(awk -F/ '{print $2}' <<< $a)\, $(awk -F. '{print $1}' <<< $(basename ${a})| tr -d 'D'); echo \, http://www.planalto.gov.br/ccivil_03/Atos/${a}; done
Resultado:
1975, 76117, http://www.planalto.gov.br/ccivil_03/Atos/decretos/1975/D76117.html 1975, 76119, http://www.planalto.gov.br/ccivil_03/Atos/decretos/1975/D76119.html 1975, 76120, http://www.planalto.gov.br/ccivil_03/Atos/decretos/1975/D76120.html 1975, 76137, http://www.planalto.gov.br/ccivil_03/Atos/decretos/1975/D76137.html 1975, 76154, http://www.planalto.gov.br/ccivil_03/Atos/decretos/1975/D76154.html 1975, 76163, http://www.planalto.gov.br/ccivil_03/Atos/decretos/1975/D76163.html 1975, 76215, http://www.planalto.gov.br/ccivil_03/Atos/decretos/1975/D76215.html 1975, 76248, http://www.planalto.gov.br/ccivil_03/Atos/decretos/1975/D76248.html 1975, 76249, http://www.planalto.gov.br/ccivil_03/Atos/decretos/1975/D76249.html 1975, 76250, http://www.planalto.gov.br/ccivil_03/Atos/decretos/1975/D76250.html 1975, 76252, http://www.planalto.gov.br/ccivil_03/Atos/decretos/1975/D76252.html 1975, 76280, http://www.planalto.gov.br/ccivil_03/Atos/decretos/1975/D76280.html
sep=';'; find decretos/*/D?????.htm[l]|sort -u|while read a; do echo "$(awk -F/ '{print $2}' <<< $a)${sep} $(awk -F. '{print $1}' <<< $(basename ${a})| tr -d 'D')${sep} http://www.planalto.gov.br/ccivil_03/Atos/${a}"|tee -a ~/projetos/saj_projects/data/atos.csv; done
2017; 09248; http://www.planalto.gov.br/ccivil_03/Atos/decretos/2017/D09248.html 2017; 09253; http://www.planalto.gov.br/ccivil_03/Atos/decretos/2017/D09253.html 2017; 09254; http://www.planalto.gov.br/ccivil_03/Atos/decretos/2017/D09254.html 2017; 09255; http://www.planalto.gov.br/ccivil_03/Atos/decretos/2017/D09255.html 2017; 09257; http://www.planalto.gov.br/ccivil_03/Atos/decretos/2017/D09257.html 2017; 09258; http://www.planalto.gov.br/ccivil_03/Atos/decretos/2017/D09258.html 2018; 09280; http://www.planalto.gov.br/ccivil_03/Atos/decretos/2018/D09280.html 2018; 09351; http://www.planalto.gov.br/ccivil_03/Atos/decretos/2018/D09351.html

Comentários