From 2f1a323bd00f90ca0b8a2627bbfaac5626637328 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Sun, 15 Apr 2018 18:52:52 +0100 Subject: [PATCH] /home/nico/.bashrc --- etc/profile.d/functions | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/etc/profile.d/functions b/etc/profile.d/functions index c9f1f36b..b9fce3e1 100644 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -771,15 +771,19 @@ END { } # NB 13.04.18: TODO -# NB 13.04.18 file_to_utf8() { -# NB 13.04.18 local usage="file_to_utf8 [FILES|DIRS]" -# NB 13.04.18 find $@ -type f | while read file; do -# NB 13.04.18 enc=$(file --mime-encoding "$file" | sed 's/^.*\? \([^ ]\+\)$/\1/' | awk '{print tolower($0)}') -# NB 13.04.18 #file --mime-encoding "$file" -# NB 13.04.18 printf '%s : ' "$file" -# NB 13.04.18 iconv -f "$enc" -t utf-8 "$file" | wc -c -# NB 13.04.18 done -# NB 13.04.18 } +file_to_utf8() { + local usage="file_to_utf8 [FILES|DIRS]" + find $@ -type f | while read file; do + enc=$(file --mime-encoding "$file" | sed 's/^.*\? \([^ ]\+\)$/\1/' | awk '{print tolower($0)}') + case "$enc" in + iso*) [ 1 ] ;; + *) continue; + esac + #file --mime-encoding "$file" + printf '%s : %s : ' "$enc" "$file" + iconv -f "$enc" -t utf-8 "$file" | wc -c + done +} file_user() { ls -dl "$1" | awk '{print $3}' -- 2.47.3