Mudar charset e quebra de linha recursivamente no Linux

26 Fev

A algum tempo atrás precisei passar uma aplicação web que utilizava quebras de linha no formato linux e charset iso-8859-1 (US-Latin) para UTF-8 com quebra de linha no formato windows. Na época codifiquei com a ajuda do chronos este script que agora compartilho:

#!/bin/sh
#change extensions filter as you need ;)
find -type f | egrep ".php|.css|.js|.html|.htm" | egrep -v ".svn" > ./charset_list.txt;
while read -r line;do
	#charset change
	iconv -f LATIN1 -t UTF-8 "$line" > "${line}2";
	mv "${line}2" "$line";
	#we adopted dos format for line breaks
	unix2dos "${line}";
done < ./charset_list.txt > ./charset_after.log 2>&1 #receive list of params and send output to log

Explicações: O script gera uma lista com todos os arquivos da pasta onde ele se encontra e suas subpastas subsequentes (conforme o filtro explicado na segunda linha do código).

Depois ele lê a lista e aplica as alterações num arquivo cópia. Move o arquivo sobre o anterior e depois altera as quebras de linha. Bastante simples, I LOVE BASH!

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

15 Responses to “Mudar charset e quebra de linha recursivamente no Linux”

  1. ADS1SPrice dezembro 19, 2013 at %H:%M 05Thu, 19 Dec 2013 05:09:50 +000050. #

    four-sensor antilock brakes with electronic brake force distribution (EBD). Kia says the EBD system adapts to individual wheel grip conditions to help improve the minivan’s control and stability.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  2. Aaron Kiphart novembro 16, 2013 at %H:%M 09Sat, 16 Nov 2013 21:10:56 +000056. #

    Wow, wonderful blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your web site is great, let alone the content!. Thanks For Your article about Mudar charset e quebra de linha recursivamente no Linux | Dev With Passion .

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  3. baju bayi abril 24, 2012 at %H:%M 06Tue, 24 Apr 2012 06:43:39 +000039. #

    Hey There. I found your blog using msn. This is a really well written article. I will make sure to bookmark it and return to read more of Mudar charset e quebra de linha recursivamente no Linux | Dev With Passion . Thanks for the post. I will definitely comeback.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  4. Marlboro cigarette abril 19, 2012 at %H:%M 01Thu, 19 Apr 2012 13:22:40 +000040. #

    Our store delivers you the Parliament king size cigarettes, Parliament mild/blue cigarettes, Parliament 100’s cigarettes and Parliament 100’s mild/blue cigarettes. Cheap Parliament Silver cigarettes.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  5. Vickey Skar abril 19, 2012 at %H:%M 12Thu, 19 Apr 2012 12:24:42 +000042. #

    I really like what you’ve done with the thmeme but I was asking myself if you are the one that created it or you just bought it and customized it?

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  6. wheres my water apk abril 18, 2012 at %H:%M 04Wed, 18 Apr 2012 04:40:41 +000041. #

    I am not sure where you are getting your info, but great topic. I needs to spend some time learning more or understanding more. Thanks for magnificent information I was looking for this information for my mission.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  7. Soczewki Allegro abril 11, 2012 at %H:%M 05Wed, 11 Apr 2012 17:55:23 +000023. #

    Attractive section of content. I just stumbled upon your website and in accession capital to assert that I get in fact enjoyed account your blog posts. Any way I will be subscribing to your feeds and even I achievement you access consistently rapidly.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  8. best cigarettes abril 11, 2012 at %H:%M 09Wed, 11 Apr 2012 09:53:02 +000002. #

    Winston cig tastes very good like a cigarette need to. This is Winston’s superiority over "rival" cig makes.Discount Winston Lights blue cigarettes.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  9. Eulalia Labreche abril 9, 2012 at %H:%M 10Mon, 09 Apr 2012 10:18:43 +000043. #

    Sorry for the huge review, but I’m really loving the new Zune, and hope this, as well as the excellent reviews some other people have written, will help you decide if it’s the right choice for you.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  10. sex abril 6, 2012 at %H:%M 08Fri, 06 Apr 2012 20:23:16 +000016. #

    Congratulations on your site that is always open to innovation. Thank you Free Porn, porno, sex, xxx management rokettubee.us Thank youu videos

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  11. Dubstep DJ abril 3, 2012 at %H:%M 04Tue, 03 Apr 2012 16:19:39 +000039. #

    My dance team coach is making us make a music video for a project and it has to tell a story and my group has a storyline but we don’t know what song it should go to The storyline is about a girl who wants to do her own dance thing but is forced to do ballet and in the end ends up doing her own thing without caring what people want her to do Anyone have song suggestions?

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  12. hguhf 'fo abril 2, 2012 at %H:%M 12Mon, 02 Apr 2012 12:28:57 +000057. #

    I would like to thnkx for the efforts you have put in writing this site. I’m hoping the same high-grade web site post from you in the upcoming also. In fact your creative writing skills has encouraged me to get my own site now. Actually the blogging is spreading its wings fast. Your write up is a great example of it.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  13. Melissia Isabelle março 26, 2012 at %H:%M 02Mon, 26 Mar 2012 14:52:57 +000057. #

    I really like how you create as well as the theme on your blog, Did a person signal this yourself or was this made by an expert? I’m very very impressed.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  14. strategi belajar saham março 25, 2012 at %H:%M 11Sun, 25 Mar 2012 23:15:09 +000009. #

    I like this blog very much so much great information.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  15. Biuro Podrozy março 23, 2012 at %H:%M 11Fri, 23 Mar 2012 23:06:13 +000013. #

    Hey very cool web site!! Man .. Beautiful .. Amazing .. I’ll bookmark your site and take the feeds also…I’m happy to find numerous useful information here in the post, we need work out more techniques in this regard, thanks for sharing. . . . . .

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)

Leave a Reply