Reputation: 165
Original format of the file (space separated):
a b http://c.com/?longlongname e f g
I want to trim the 3rd field (http://c.com/?longlongname
) into c.com
, and
keep the rest fields as the same. I would like to use awk
to do this task.
Could anyone give me any hint?
Upvotes: 0
Views: 281
Reputation: 1
awk '{split($3, z, "/"); $3=z[3]} 1'
/
Result
a b c.com e f g
Upvotes: 3