08-16-2007
2,
0
Join Date: Aug 2007
Last Activity: 5 October 2007, 2:54 PM EDT
Posts: 2
Thanks Given: 0
Thanked 0 Times in 0 Posts
sed is cool , but got just this one problem ...
Hi all,
I have this very strange (and tiring) trouble with sed (or any command that works with files for that matter)
I need to do the following
1. I have a string say "UTN555"
2. I need to extract just the last three digits
3. I did this
echo UTN555 | sed "s/UTN//"
4. Seems pretty simple, but here comes the trouble. If "UTN555" is just any random string, I get the correct result ==> 555
5. The problem is when UTN555 is a file. In this case , sed (or even cut for that matter) interprets it as a file and works on the contents of this file, which is
not what I want to do.
Can you guys please help me figure this one out ??
I got a work around for this , but I think there must be a way to suppress this mis-interpretation. my work around
1. Dump UTN555 into a file
2. Give this file as input to sed.
As for googling , I am at loss for keywords to describe this problem.
Hope that explains the problem. Thanks in advance ppl.
cheers