[PLUG] cut delimiter question

Chris Berry cberry at davistl.com
Mon Jun 11 16:07:39 UTC 2012


The problem with cut is that it's really picky.  You could get close with: 

ls -alh | cut -f11 -d'  ' 

but due to various file sizes sometimes you'll get the wrong field due to extra spaces.  So you'd end up running something else to delete the extra spaces first.  For your specific problem you could do this: 

ls -alh | tr -s ' ' | cut -f9 -d' ' 

Oh by the way, is etiquette here to reply all or reply list?


Chris Berry
Linux Systems Administrator
Davis Tool
x521

>>> Rich Shepard <rshepard at appl-ecosys.com> 6/11/2012 8:23 AM >>>
On Mon, 11 Jun 2012, Chris Berry wrote:

> I would generally use awk to do that, something like this:
> ls -alh | awk '{print $9 }'

Chris,

   I thought of that but figured cut would be the better way. Apparenly not.

Thanks,

Rich

_______________________________________________
PLUG mailing list
PLUG at lists.pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug



More information about the PLUG mailing list