Link to home
Start Free TrialLog in
Avatar of nlrreddy
nlrreddy

asked on

ignore the last field using awk

Hi,

How can I ignore the last field from the standard out and display the remaining

Suppose, my initial standard output is

SVN/developer/apps/dbtake/tags/rel-111/trunk/bveri.inc
SVN/developer/apps/dbtake/tags/rel-111/trunk/adanc/yellowt.html

the awk command should be able to display only until

SVN/developer/apps/dbtake/tags/rel-111/trunk/
SVN/developer/apps/dbtake/tags/rel-111/trunk/adanc/

How can I do this using awk.

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of rangasuman
rangasuman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is awk -
echo "SVN/developer/apps/dbtake/tags/rel-111/trunk/bveri.inc" | awk -F/ '{for(i=1;i<NF;i++) O=O$i"/"; print O; O=""}'
generally
some_command | awk -F/ '{for(i=1;i<NF;i++) O=O$i"/"; print O; O=""}'
This is built-in variable editing -
echo "SVN/developer/apps/dbtake/tags/rel-111/trunk/bveri.inc" | while read line; do line=${line%/*}; echo $line/; done
some_command  | while read line; do line=${line%/*}; echo $line/; done
I guess someone will soon come up with sed ...
 
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nlrreddy
nlrreddy

ASKER

best solution by all the three