]> git.nbdom.net Git - nb.git/commitdiff
/home/nico/.bashrc
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 15 Apr 2018 17:52:52 +0000 (18:52 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 15 Apr 2018 17:52:52 +0000 (18:52 +0100)
etc/profile.d/functions

index c9f1f36be3d58be46055df8e10e0cee6dc71f628..b9fce3e16ab20159e670fddaa9e0eb25c974e8e4 100644 (file)
@@ -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}'