Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String filteration with Sed

Status
Not open for further replies.

ranjank

IS-IT--Management
May 9, 2003
176
0
0
IN
Hi,

I want to filter one string from the line.

E.G :

:abc:ranjan@127.0.0.1:/u/project

I wan to extracr ranjan from the above line.Can any one give me any pointers as how to extract with sed or awk.Any help on this will be appreciated.

Regards,
Rajan.
 
Some pointers: You can use sed s command to first replace the string '@.*' with the null string and then replace the string '.*:' with the null string, which leaves the word before the '@' but after the preceding ':'.
Another tip: using ; command separator character you can specify both s commands in one sed command line.

See sed man page for more info.


HTH,

p5wizard
 
Hi

Pointer b) : Capture the string preceding the monkey tail ( @ ) composed by any number of non-colon ( : ) characters and replace the whole string with the captured part.

Tip b) : search this forum.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top