That tweak is incorrect, if I understand the modification to f2 correctly. If the second field is greater than the third, then it instead of being treated as the beginning index of the substring, it should be considered the end index (and the interpretation of the third field should be complementarily swapped). The correct solution requires that the second argument to substr() be modified as well, since in the case of $2 > $3, it should be $3 not $2.
By the way, malcomeex999 and rdcwayx, thank you very much for your bit awards. It's appreciated
Hi, patrick87:
One solution to handle both cases (even if they appear within the same file2):
It works identically to my earlier solution except that it tests the second and third fields in f2. If the first index is greater than the second, their values are swapped before the substr() call.
Regards,
Alister
Hi Alister,
i guess we both understood the changes to f2 differently.
From what i understood,if it is like below
it should fetch 5 characters starting from 15th character. But in your way, you are swapping it so it will fetch 15 characters starting 5th character. But as long as the OP didn't show the desired output, we have to wait and see his reply.
Hi alister,
Your awk code work perfectly for both of my cases
Really thanks a lot for your sharing. It is fantastic and work perfectly.
Thanks again.
---------- Post updated at 01:47 AM ---------- Previous update was at 01:39 AM ----------
Hi malcomex999,
Thanks a lot for your help too.
Sorry if my second problem case leads to your misunderstanding.
Actually for both problem case, I would like to obtain the same output result:
No matter how I alter the range of column 2 and column 3 from the input file 2.
Anywhere I appreciate your awk sharing too
Thanks again, malcomex999 ^^
Hi all,
I am working on a small prog..
i have a file.txt which contains random data...
K LINES V4 ADD CODE `COMPANY` ADD CODE `DISTRIBUTOR` SEQ NAME^K LINES V5 SEQ NAME^K LINES V6 ADD `PACK-LDATE` SEQ NAME^K^KCOMMAND END^KHEADINFO... (1 Reply)
Dear all-
I have a requirement to send an email via email with body content which looks something below-
Email body contents
--------------------
RequestType: Update
DateAcctOpened: 1/5/2010
Note that header information and data content should be normal text..
Please advice on... (5 Replies)
My input:
Data name: ABC001
Data length: 1000
Detail info
Data Direction Start_time End_time Length
1 forward 10 100 90
1 forward 15 200 185
2 reverse 50 500 450
Data name: XFG110
Data length: 100
Detail info
Data Direction Start_time End_time Length
1 forward 50 100 50 ... (11 Replies)