scuzz1
asked on
Splitting a text file into seperate text files.
I get a text file with a long list of filenames that looks like this:
a52372,CH-A-00-00-02-00A-0 40A-A
a58758,CH-A-00-00-03-00A-0 12B-A
a58759,CH-A-00-00-03-00A-0 12B-A
a58760,CH-A-00-00-03-00A-0 12B-A
a65855,CH-A-06-40-00-00A-0 10A-A
a58883,CH-A-06-40-01-00A-5 40A-A
a58884,CH-A-06-40-01-00A-5 40A-A
a65855,CH-A-06-40-01-00A-5 40A-A
a62128,CH-A-06-40-01-00A-5 40A-A
a65817,CH-A-08-40-00-00A-0 30A-A
a65818,CH-A-08-40-00-00A-0 30A-A
a53077,CH-A-08-40-00-00A-0 30A-A
I need to be able to send all the files with CH-A-00 to one file and CH-A-06 to another and CH-A-08 to another and so on. The number in the 13th and 14th position determines what file they need to go. I can't grep those positions because they change and I never know what they're going to be. The letters in front of those postions change to.
Is there a way to cut that number out and save it to a variable then use the variable in a for loop or if statement then goto the next line?
jas
a52372,CH-A-00-00-02-00A-0
a58758,CH-A-00-00-03-00A-0
a58759,CH-A-00-00-03-00A-0
a58760,CH-A-00-00-03-00A-0
a65855,CH-A-06-40-00-00A-0
a58883,CH-A-06-40-01-00A-5
a58884,CH-A-06-40-01-00A-5
a65855,CH-A-06-40-01-00A-5
a62128,CH-A-06-40-01-00A-5
a65817,CH-A-08-40-00-00A-0
a65818,CH-A-08-40-00-00A-0
a53077,CH-A-08-40-00-00A-0
I need to be able to send all the files with CH-A-00 to one file and CH-A-06 to another and CH-A-08 to another and so on. The number in the 13th and 14th position determines what file they need to go. I can't grep those positions because they change and I never know what they're going to be. The letters in front of those postions change to.
Is there a way to cut that number out and save it to a variable then use the variable in a for loop or if statement then goto the next line?
jas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Never mind the last comment. I figured it out. I'm going to try to work in the textfiles I need. I think this will work.
ASKER
Excellent. I was really stuck. I couldn't get the thing to slow down and read the file one line at a time.
Thanks much,
jas
Thanks much,
jas
You're welcome. Just glad I could help.
ASKER