sed is cool , but got just this one problem ...


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users sed is cool , but got just this one problem ...
# 1  
Old 08-16-2007
Java 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
# 2  
Old 08-16-2007
# 3  
Old 08-16-2007
woooow it worked !!! . though I dont fully recognize the syntax (gotta google I guess). Thanks a ton Perderabo
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Cool stuff with command line?

Hi there, I just switch to MAC and love the way command line do things like mass renaming, unrar, remove .... in terminal, so better than normal graphic apps. I love to study more about this stuff, could you guys show me some book that help me out, Simply I see many code like this in internet but... (1 Reply)
Discussion started by: silverhan31
1 Replies

2. Web Development

Cool Google Search Mashups

One of my favorite mashups is the Google search mashup. You can see it here at the top right hand corner of the site; where you enter a normal Google search work or phrase and Google serves the result, mashedup, back into your site. The same is true on The CEP Blog, where there the same... (0 Replies)
Discussion started by: Neo
0 Replies

3. What is on Your Mind?

Cool new logo

I saw this on another board, and burst out laughing. http://www.brandsoftheworld.com/brands/0011/0070/brand.gif Apparently it's a new logo (may even be a new name) for a clothing line. Check them out: www.A-Style.it (9 Replies)
Discussion started by: Dave Miller
9 Replies

4. What is on Your Mind?

Cool video

Grand Central Big Freeze jwMj3PJDxuo It looks as tho it's movie scene from M. Night Shyamalan :b: (0 Replies)
Discussion started by: sparcguy
0 Replies
Login or Register to Ask a Question