Computing.Net > Forums > Unix > need help with grep....

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

need help with grep....

Reply to Message Icon

Name: chrisgr
Date: April 6, 2006 at 15:08:24 Pacific
OS: unix
CPU/Ram: 1.5 Pentium4 256Mb
Product: Intel
Comment:

I have a .txt file which contains several lines of text. I need to write a script program using grep or any other unix tool so as to detect part of the text(words) between / / that begin with the symbol ~.For example if somewhere in the text appears a webpage address like
http://www.cs.may.ie/~dtray/cs211/lecture1.htm, my program must print only the word dtray(the symbol ~ must be ommited)

I would really appreciate any help...



Sponsored Link
Ads by Google

Response Number 1
Name: Chinmaya
Date: April 17, 2006 at 23:41:17 Pacific
Reply:

Hi

You can use the grep and cut commands as given below:

grep '/~*/' <.txt file name> | cut -d '~' -f 2 | cut -d '/' -f 1

Note : This command works , if your text file contains the line of format : http://www.cs.may.ie/~dtray/cs211/lecture1.htm

Thanks and Regards,
Chinmaya

Thanks and Regards
Chinmaya


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: need help with grep....

Need help with sorting a file www.computing.net/answers/unix/need-help-with-sorting-a-file/6971.html

need help with finger command. www.computing.net/answers/unix/need-help-with-finger-command/4284.html

I need help with my skript. www.computing.net/answers/unix/i-need-help-with-my-skript/5903.html