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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AWK query.

Status
Not open for further replies.

ranjank

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

I want to print the 2nd part of the sentence in the first coulmn.

For E.g

I want to filter the output project:ranjan which is in the first column in the file.I want to print only ranjan.How can i get this.

--Ranjan.
 
Thanks a lot.

Its working with gsub.

--Ranjan.
 

There is one issue:

There is a space between project: and ranjan

project: ranjan

How can i remove the space with

awk '{gsub(/.*:/,"",$1);print $1}' /path/to/input

Regards,
Ranjan.
 
Hi

The [tt]awk[/tt] will split the line on spaces, so the word "ranjan" will be placed in $2 :
Code:
awk '{print $2}' /path/to/input
If that space is not allways there, the problem become abit complicated. If there is nothing after the word "ranjan", then :
Code:
awk '{gsub(/.*: ?/,"");print}' /path/to/input
Otherwise, post a full input line.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top