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-1 11/trunk/b veri.inc
SVN/developer/apps/dbtake/ tags/rel-1 11/trunk/a danc/yello wt.html
the awk command should be able to display only until
SVN/developer/apps/dbtake/ tags/rel-1 11/trunk/
SVN/developer/apps/dbtake/ tags/rel-1 11/trunk/a danc/
How can I do this using awk.
Thanks,
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/
SVN/developer/apps/dbtake/
the awk command should be able to display only until
SVN/developer/apps/dbtake/
SVN/developer/apps/dbtake/
How can I do this using awk.
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
best solution by all the three
echo "SVN/developer/apps/dbtake
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
some_command | while read line; do line=${line%/*}; echo $line/; done
I guess someone will soon come up with sed ...