frnds:
i want to divide data on the behalf of dotted line and redirectd into new files
)
-------------------------
M-GET CONFIRMATION (
-------------------------
M-GET CONFIRMATION (
INVOKE IDENTIFIER
final data shuld be into 3 files ... file1 file2 file3
clx
April 11, 2012, 5:58am
2
Please give us more clue. Expected input and output.
input data mentioed above:
output shud be:
) -- shud be in file1
-------------------------
M-GET CONFIRMATION ( shud be in file 2
-------------------------
M-GET CONFIRMATION ( shud be in file3
INVOKE IDENTIFIER
after every doted line data shud be redirected into a new file$
Hi
awk '!/^---/{print > "File"i;next}{i++}' i=1 inputfile
Guru.
its not working ... i want on every repeation of dotted line it create a new file and redirect that paragraph into dat file
awk 'BEGIN{i=1} {print $0 > "File_no"i;if (/^-----/) {++i}}' filename
Ygor
April 12, 2012, 4:59am
7
You can use csplit...
$ cat infile
)
-------------------------
M-GET CONFIRMATION (
-------------------------
M-GET CONFIRMATION (
INVOKE IDENTIFIER
$ csplit --prefix='outfile' infile '/----------/' '{*}'
25
52
75
$ head outfile??
==> outfile00 <==
)
==> outfile01 <==
-------------------------
M-GET CONFIRMATION (
==> outfile02 <==
-------------------------
M-GET CONFIRMATION (
INVOKE IDENTIFIER
...or if you don't want the line of dashes in the output files, then try awk...
$ awk '/----------/{close(f);i++;next}{f=sprintf("outfile%02d",i);print > f}' infile
$ head outfile??
==> outfile00 <==
)
==> outfile01 <==
M-GET CONFIRMATION (
==> outfile02 <==
M-GET CONFIRMATION (
INVOKE IDENTIFIER
$