Change encoding of multiple files with icon in bash

I want to change the encoding of multiple php files using the icon.

I use the find and exec options (link: http://linux.bigresource.com/Ubuntu-Encoding-Conversion-on-Multiple-Files--4fuXvUwbN.html )

find . -type f -name '*.php' -print -exec iconv -f euc-kr -t utf-8 {} -o {}.utf8 

But an error has occurred.

 find: missing argument to `-exec' 

I just want to convert all php files at once. How can I do this with a single statement in bash?

+4
source share
2 answers

You must put either \; , or + at the end of the -exec action.

 find . -type f -name '*.php' -print -exec iconv -f euc-kr -t utf-8 {} -o {}.utf8 \; 
+4
source

after some tests finally found a solution working on my mac

 for f in *.TXT; do iconv -f CP1250 -t utf-8 $f > $f.txt; done 
+3
source

Source: https://habr.com/ru/post/1481297/


All Articles