Save Separate Columns Into Separate Files using Awk

Assume that you have a column of data and you want to separate each column into it's own file.

It's relatively easy in awk.

Input is a sha256 or hash of ebooks:

1~$ sha256sum *.pdf
29scac1ae26617a210e2211cce308aa2b770b08cb51f46621b13be272877cc068  ebook1.pdf
3edbd3d4419878ee9ab68b211fc69e145eb776309273ab467e2f1bdc912d0252a  ebook2.pdf

and script is as follows:

1~$ sha256sum *.pdf|awk '{
2        for(i=1;i<=NF;i++) print $i > ("temp_hash" i)
3      }'

It produces two file outputs (since we only have two columns.

temp_hash1 - containing the first column (or the hash

1~$ cat temp_hash1 
29scac1ae26617a210e2211cce308aa2b770b08cb51f46621b13be272877cc068
3edbd3d4419878ee9ab68b211fc69e145eb776309273ab467e2f1bdc912d0252a

temp_hash2 - containing the filename

1~$ cat temp_hash2
2ebook1.pdf
3ebook2.pdf

CREDITS: https://stackoverflow.com/questions/48933100/awk-print-each-column-of-a-file-into-separate-files