#!/bin/bash

read -p "4文字の英大文字を入力: " s
if expr ${s} : "[A-Z]\{4\}$" > /dev/null ; then
  echo ${s:0:1} > _tmp
  echo ${s:1:1} >> _tmp
  echo ${s:2:1} >> _tmp
  echo ${s:3:1} >> _tmp
  if [ "`cat _tmp | sort | uniq -c | awk '{print $1}' | sort | uniq -c | xargs`" = "2 2" ]; then
    echo "Yes"
  else
    echo "No"
  fi
else
  echo "No"
fi