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

remove last column

Status
Not open for further replies.

praywin

Programmer
Feb 6, 2003
31
IN
Hi,
I want a awk script which will not print the last column of the line.
Say my input is

/usr/local/bin/gdb
/u/src/bin/ddd

I want the output to be

/usr/local/bin
/u/src/bin

awk -F/ '{for(i=1;i<NF;i++) {print &quot;/&quot;$i}}'

gives me

/usr
/local
/bin
/u
/src
/bin

I want them printed in one line at a time.
Any suggestions
Cheers,
Pravin.
 
nawk 'BEGIN{FS=OFS=&quot;/&quot;} {$NF=&quot;&quot;;print}' vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top