Replace UTF-8 characters with shell perl
Use this :
$ echo 'ABCæøåDEF' |
perl -CSD -Mutf8 -pe 's/([æøå])/[$1]/g'
Works also for files
Output :
ABC[æ][ø][å]DEF
Note :
- substitutions:
\\1
is for awk,\1
is for sed and in perl we use$1
- check
perldoc perlrun
for-CSD
utf8 tricks