BASH | detect text files charset and convert to …

MOD_INTRO_FILE_CHARSET=”$(file -bi “$MOD_INTRO_FILE” | grep charset | sed “s|.*\=||” | awk ‘{print $1}’)” if [ “x$MOD_INTRO_FILE_CHARSET” != “x” ]; then $(which iconv) -l | grep -wi $MOD_INTRO_FILE_CHARSET > /dev/null if [ $? -eq 0 ]; then MOD_INTRO=”$(cat “$MOD_INTRO_FILE” | $(which iconv) -cs -f $MOD_INTRO_FILE_CHARSET -t $CHARSET_TEXTFILE)” else MOD_INTRO=”$(cat “$MOD_INTRO_FILE”)” fi else MOD_INTRO=”$(cat “$MOD_INTRO_FILE”)” fi

Bash | compare two arrays | compare two strings

comm -12 <(printf ‘%s\n’ “${ARRAY1[@]}” | LC_ALL=C sort) <(printf ‘%s\n’ “${ARRAY2[@]}” | LC_ALL=C sort) comm -12 <(printf ‘%s\n’ ${STRING1} | LC_ALL=C sort) <(printf ‘%s\n’ ${STRING2} | LC_ALL=C sort)