怎么找到一个目录下所有的.txt文件并且读取每个文件第一行内容到a.out文件里使用bash?

这样写为什么错了,,,呃呃呃bash刚刚接触一丢丢,轻点批

 cd 'find ./ -name "%.txt" | sed -n "1p">a.out

本来想用for file in 路径
if 判断 文件是不是.txt
do 读取第一行 到a.out
done
但是总是报错,就是这样,,,,,

不好意思,格式错了。

 #!/bin/bash

for f in `ls *.txt`
do  
 head -n 1 $f >> a.out
done  

#!/bin/bash

for f in ls *.txt
do

head -n 1 $f >> result.log
done