Hi All,
I am trying to manipulate a text file in a csh script I am writing. I just started scripting a few months ago and have NO idea how to get this to work. My ultimate goal is to turn a text file that looks like this:
4 ep2d_diff_mddw_20_p2-MOD err 128 128 64 62 52611737
2 MPRAGE ok 256 240 160 1 52616379
3 MPRAGERepeat ok 256 240 160 1 52615691
10 AxialPD-T2TSE ok 256 228 48 2 52607078
11 ep2d_bold_moco ok 64 64 36 120 52605446
12 ep2d_bold_moco ok 64 64 36 120 52604109
16 t2_spc_ns_sag_p2_da-fl_iso-MOD ok 256 256 176 1 52602792
Into this:
2 3danat MGZ 002.mgz
3 3danat MGZ 003.mgz
4 diff MGZ 004.mgz
10 AxialPD MGZ 010.mgz
11 ge_funk MGZ 011.mgz
12 ge_funk MGZ 012.mgz
16 t2_space MGZ 016.mgz
Where always,
ep2d_diff_mddw_20_p2-MOD = diff
MPRAGE = 3danat
MPRAGERepeat = 3danat
AxialPD-T2TSE = AxialPD
ep2d_bold_moco = ge_funk
t2_spc_ns_sag_p2_da-fl_iso-MOD = t2_space
The big catch is that the numbers in the first column proceeding these "replacements" may differ between text files so it is impossible to hardcode for example: "2 MPRAGE" is always equal to "2 3danat" because sometimes it might be 3 MPRAGE instead.
So basically, I hope to find any suggestions for commands that might be useful in maintaining the first number in each line, using the second entry in the line to replace it with a new name, then inserting the words "MGZ" next in the line and finally using the number at the beginning of the line as a variable to insert into 00$var.mgz.
Is this even possible???? Or am I hoping for way too much?
Thanks so very very much!
Tori