remove bom from utf-8 files - gists · GitHub

文章推薦指數: 80 %
投票人數:10人

remove bom from utf-8 files. GitHub Gist: instantly share code, notes, and snippets. Skiptocontent Allgists BacktoGitHub Signin Signup Sign in Sign up {{message}} Instantlysharecode,notes,andsnippets. svortex/bomremover CreatedMay23,2013 Star 0 Fork 0 Star Code Revisions 1 Embed Whatwouldyouliketodo? Embed Embedthisgistinyourwebsite. Share Copysharablelinkforthisgist. Clonevia HTTPS ClonewithGitorcheckoutwithSVNusingtherepository’swebaddress. LearnmoreaboutcloneURLs DownloadZIP removebomfromutf-8files Raw bomremover ThisfilecontainsbidirectionalUnicodetextthatmaybeinterpretedorcompileddifferentlythanwhatappearsbelow.Toreview,openthefileinaneditorthatrevealshiddenUnicodecharacters. LearnmoreaboutbidirectionalUnicodecharacters Showhiddencharacters #!/bin/bash # #BOMRemoverv1.0 # #(c)2011,AdilAliyev #NEATSLLC #Baku/Azerbaijan # #[email protected] # functionusage(){ echo"BOMRemoverv1.0" echo"" echo"(c)2011,AdilAliyev" echo"" echo"Usage:" echo"bomremover[-r]files..." echo"-rScansubdirectories." echo"" } RECURSIVE_MODE=false whilegetopts"rh"opt do case$optin r)RECURSIVE_MODE=true;; h)usage;exit1;; *)echo"Illegaloption.";exit2;; esac done FILES="$@" if[!-n"$FILES"];then echo"bomremover:Nofilespecified" exit1 fi color_greenf="\033[01;32m" color_reset="\033[0m" if[$RECURSIVE_MODE==true];then find.-typef|whilereadfile do sed-i's/^\xef\xbb\xbf//'"$file" echo-e"$file\t\t\t${color_greenf}done.${color_reset}"; done else foriin$FILES;do sed-i's/^\xef\xbb\xbf//'$i echo-e"$i\t\t\t${color_greenf}done.${color_reset}"; done fi #EOF Signupforfree tojointhisconversationonGitHub. Alreadyhaveanaccount? Signintocomment Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.



請為這篇文章評分?