Hi,
I have a situation where I have large number of files and each of the files needs to be formatted and then all the files sequentially numbered will be merged to one large data file. For example, I have files as follows:
File 1: file_001.dat
A B C D
1 2 3
P Q R S
5 6 7
File 2: file_002.dat
E F G H
1 R 6
5 U Y T
6 1 R
etc...
I want to first format the files to:
file 1: file_001.dat
A B C D 1 2 3
P Q R S 5 6 7
file 2: file_002.dat
E F G H 1 R 6
5 U Y T 6 1 R
etc...
Once I have formatted the files, I want to make one large file containg all the files after they are formatted above:
the final file should look like:
A B C D 1 2 3
P Q R S 5 6 7
E F G H 1 R 6
5 U Y T 6 1 R
etc....
I have a script that will format each of the file individually, but I want to do a batch run where all the files will be sequentially be formatted once running the script.
Here is the script for formatting individual file:
{printf "%s",$0}
NR%2==0{printf "\n"}
END{if(NR%2)PRINTF "\n"}
These scripts works and does the formatting for each file. Can someone modify the script so that each of the files which are numbered sequentially as file_001.dat, file_002.dat ...... to file_547.dat to be formatted in one batch run.
Thanks for any help that you can provide.
I have a situation where I have large number of files and each of the files needs to be formatted and then all the files sequentially numbered will be merged to one large data file. For example, I have files as follows:
File 1: file_001.dat
A B C D
1 2 3
P Q R S
5 6 7
File 2: file_002.dat
E F G H
1 R 6
5 U Y T
6 1 R
etc...
I want to first format the files to:
file 1: file_001.dat
A B C D 1 2 3
P Q R S 5 6 7
file 2: file_002.dat
E F G H 1 R 6
5 U Y T 6 1 R
etc...
Once I have formatted the files, I want to make one large file containg all the files after they are formatted above:
the final file should look like:
A B C D 1 2 3
P Q R S 5 6 7
E F G H 1 R 6
5 U Y T 6 1 R
etc....
I have a script that will format each of the file individually, but I want to do a batch run where all the files will be sequentially be formatted once running the script.
Here is the script for formatting individual file:
{printf "%s",$0}
NR%2==0{printf "\n"}
END{if(NR%2)PRINTF "\n"}
These scripts works and does the formatting for each file. Can someone modify the script so that each of the files which are numbered sequentially as file_001.dat, file_002.dat ...... to file_547.dat to be formatted in one batch run.
Thanks for any help that you can provide.