0

I need a unix (aix) script to split a file to multiple files, basically one file per line, where the content of the file like:

COL_1 ROW 1 1 1

COL_2 ROW 2 2 2

COL_3 ROW 3 3 3

... and the name of each file is the 1st column, and the content of the file the rest of the line, something like:

Name: COL_1.log

content:

ROW 1 1 1

Thanks in advance, Tiago

Community
  • 1
  • 1
tiago
  • 39
  • 10

1 Answers1

2

Using a while loop and read each line:

cat file | while read COL REST; do
  echo $REST > $COL.log
done

COL will contain the first word of each line REST will contain the rest of the line

Ryan Groten
  • 208
  • 2
  • 7