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

Could anyone help me to sort out my text file !! 2

Status
Not open for further replies.

rao12

IS-IT--Management
Jan 10, 2001
9
0
0
US
I have a input file which looks like


john /ghsgd/kjhfdf/kjdfkjd
john /ruey/oieroiern/oieroeiroi
jim /kjskksj/kdjfkdjf/kdjfkjd
john /jdkfjd/kjdfdfjh/fjgfjg/kdfikdhf
jim /gdhfgdf/lgkfjg/orit
mike /kdjfjdk/jhjdfhjdf/jdhfjdhf/jhdjfhdjf
..............
................
many other names and many other paths. I am trying for a loop where in i get an output which is organised as below.


I would like to have an output file which looks like

===============================

john /ghsgd/kjhfdf/kjdfkjd
john /ruey/oieroiern/oieroeiroi
john /jdkfjd/kjdfdfjh/fjgfjg/kdfikdhf
====================================
jim /kjskksj/kdjfkdjf/kdjfkjd
jim /gdhfgdf/lgkfjg/orit
====================================
mike /kdjfjdk/jhjdfhjdf/jdhfjdhf/jhdjfhdjf
=====================================
......................
......................
===================================

If anyone could help me that would be great.

Thanks
Rao


 
rao12,

Please, try this solution:


sort < pathfile | awk '$1 != prev { print &quot;=====&quot; }
{ print; prev = $1 }
END { print &quot;=====&quot; }'


I hope this helps.

Bye!

KP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top