out.txtin each subfolder with first line ofinput.txtin that particular subfolder
find + sed solution:
find . -type f -name input.txt -exec sh -c 'out_fn="${1%/*}/out.txt"; sed -n "1p" "{}" > "$out_fn"' _ {} \;
out_fn="${1%/*}/out.txt"- path to output filename in format/path/to/subfolder/out.txtout_fn="${1%/*}/out.txt"- path to output filename in format/path/to/subfolder/out.txtsed -n "1p" "{}"- extracts the 1st line from the input file{}