head command with more than one file

Hi, I have the following problem. I have files with one column of data (let's say file1.dat, file2.dat...file6.dat), and I would like to record the first value of the column of each file into another file (let's name it fileall.dat), which would have the the six values, one in each column. I use to do it as follows,

head --lines=1 file_i.dat >> record_i.dat

with i={1,...,6}, and then, I pasted all with

paste -d" " record_1.dat record_2.dat ... record_6.dat > fileall.dat

and then I had the 6 first values of each data file column together in one file. Is there any way to do it all in one step?

Something like this , you can try :

awk 'FNR==1{printf("%s ",$1) }' file1.txt file2.txt  file3.txt

It works!, thanks a lot

you want first line of each file in a file?
if so try :

for line in $(ls); do head -1 $line >> myfile; done

Yes that is. With

for line in $(ls); do head -1 $line >> myfile; done

worked as well if I had the files, whose first lines I want to put together, in the same directory, but it is not like this. I've skipped the details. What I wanted is to join together the first value of 6 files named fort.605 in one file, each in a different directory, i.e:

approach1.dir/fort.605
...
approach6.dir/fort.605

The first way is straightforward, but thanks a lot