[Gllug] Utility to pull fields from lines of a file

Daniel P. Berrange dan at berrange.com
Sun Apr 13 15:18:02 UTC 2008


On Sun, Apr 13, 2008 at 04:15:24PM +0100, John Winters wrote:
> It must be old age but I've forgotten the name of a standard UNIX utility.
> 
> All I want to do is process a file containing lines like this:
> 
> able/baker/charlie
> home/made/cakes
> 
> and pull out the second field ("baker" and "made") from each one.  I 
> know I've done it a zillion times before (and you could of course do it 
> with Perl) but I'm sure there's a simple UNIX utility which does it.

# echo "able/baker/charlie" | awk -F / '{print $2}'
baker

Dan.
-- 
|: http://berrange.com/     -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://freshmeat.net/~danielpb/    -o-   http://gtk-vnc.sourceforge.net :|
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20080413/7f6425e7/attachment.pgp>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list