yes, it worked perfectly. Thanks so much. However, I am trying to learn awk and sed. I don't know perl and i just run your code to get the result. But, i need to know how to do it in Sed or awk. i did the following codes to get my results. it is a two-stage work:
1) i changed the third "." to other unique char (#) and save in a temporary file (out1)
sed 's/\./#/3' inputfile.txt > out1
then, i deleted the values between the patterns
sed 's/#.*[\t]/\t/' out1 > out2
where out2 is the final output. I got the right output but, i want a sed or awk code that only one liner as your perl. Thanks
If the file uses a tab delimiter and there is only 1 per line:
sed 's/\./\t/3; s/\t.*\t/\t/' file
That isn't portable sed, because \t is primarily a GNU extension. However, if it worked for you, and you only care about that platform, it should suffice.
If you would tell us what system you're using, we'd have a better chance of giving you working code. There are significant differences between how sed behaves with back references depending on which sed you're using.
Apparently you are not using Mac OS X and you are not using any version of Linux. What OS are you using?
I should have said BREs rather than back references, but the times I most often see a sed substitute command fail is when I'm using back references. On the Linux sed man page provided in these forums, you'll find:
I don't currently have access to a Linux system and I can't give a clear statement of what POSIX.2 BRE features are not supported by the Linux sed utility, but I have seen several cases in these forums where a standards conforming sed script (such as the one protocomm posted in this thread:
sed -n 's|\([0-9]*\.[0-9]*\.[A-Z0-9]*\)\(\.[0-9]*\.[0-9]*\)\(.*\)|\1\3|p'
or a similar suggestion I would have made until I saw protocomm's suggestion and the statement that it didn't work:
sed 's/^\([[:alnum:]]*[.][[:alnum:]]*[.][[:alnum:]]*\)[.[:alnum:]]*/\1/' input.txt
) fail on the GNU utilities version of sed but work as specified by the standards with an AIX, HP/UX, OS X, or Solaris system sed utility.