#!/bin/bash

# ideone boilerplate: run in temp dir 
t=$(mktemp -d -t ideone.XXXXXXXX) || exit
trap 'rm -rf "$t"' ERR EXIT
cd "$t"

mkdir -p seq

cat <<\_ >seq/one.txt
>first sequence
aaaaaaaaa
>second_sequence
ccccccccc
_

cat <<\_ >seq/two.txt
>third sequence
ggggggggg
ggggggggg
> fourth sequence
tttttt
tttttt
_

echo "** OP's attempt"

awk 'BEGIN {RS=">"} {print $1}' seq/*.txt
awk 'BEGIN {RS=">"} {print toupper ($2)}' seq/*.txt

echo '** Solution'

awk '/^>/ {
  if (n) printf "\n"
  n = 0
  sub(/>[[:space:]]*/, "")
  print >>"headers.txt"
  next
}
{ printf("%s", toupper($1)); n=1 }
END { if (n) printf "\n" }' seq/*.txt >sequences.txt

cat headers.txt sequences.txt