apply record separator to multiple files within a directory using awk

Hi,

I have a bunch of records within a directory where each one has this form:

(example file1)

1 2 50 90 80 90 43512 98  0909  79869 -9 7878   33222   8787 9090   89898  7878  8989   7878  6767  89 89  78676  9898    000   7878   5656   5454  5454

and i want for all of these files to be transformed into single column files.

using awk from the command line i tried:

awk 'BEGIN{RS=" ";}{print;}' file*.txt > new_file*.txt  

it worked in all file*.txt but the output was written into one single output file new_file*.txt ...is there a way to redirect the output to multiple files?

(i.e. for a file1.txt there should be its single columned resulted file printed in new_file1.txt)

thanks in advance

Something like this?

awk '{print > "new_" FILENAME}' RS=" " file*.txt
1 Like
nawk 'FNR==1{x="new_" FILENAME}{print $0 > x}END{close(x)}' RS=" " file*.txt

yes! exactly like this!

thank you Franklin52!