unix - Save each line as a separate file -


i save each line of file separate file, using column 1 name of file

at1g01010       chr1    3631    5899 at1g01020       chr1    6790    8737 at1g01030       chr1    11649   13714 

desired output separate file at1g01010.txt contents are

at1g01010       chr1    3631    5899  

i know in vim possible using command

:g/^/execute '.w '.line('.').'.txt' 

but generates file named after line number, not result want.

try script:

while read line     name=`echo $line | awk '{print $1}'`     echo "$line" > $name.txt done < source_file.txt 

Comments