cut can use other delimiters besides spaces. And can, helpful in this case, 
choose arbitrary byte offsets:

    michael@bivy /srv/photo/365_2012 % ls -l | head 
    total 706024
    drwxrwxr-x 10 michael michael     36864 Feb 16  2015 2012
    drwxrwxr-x  2 michael michael     12288 Jul  8 14:21 2013
    drwxrwxr-x 32 michael michael      4096 Jan  6  2013 2013_01_Jan
    drwxrwxr-x 28 michael michael      4096 Nov 11  2012 2013_02_Feb
    drwxrwxr-x 31 michael michael      4096 Jul  8 14:21 2013_03_Mar
    drwxrwxr-x 27 michael michael      4096 Jul  8 14:21 2013_04_Apr
    drwxrwxr-x 32 michael michael      4096 Jul  8 14:21 2013_05_May
    drwxrwxr-x 30 michael michael      4096 Jul  8 14:21 2013_06_Jun
    drwxrwxr-x 33 michael michael      4096 Jul  8 14:21 2013_07_Jul
    michael@bivy /srv/photo/365_2012 % ls -l | head | cut -b1-10,53- 
    total 7060
    drwxrwxr-x 2012
    drwxrwxr-x 2013
    drwxrwxr-x 2013_01_Jan
    drwxrwxr-x 2013_02_Feb
    drwxrwxr-x 2013_03_Mar
    drwxrwxr-x 2013_04_Apr
    drwxrwxr-x 2013_05_May
    drwxrwxr-x 2013_06_Jun
    drwxrwxr-x 2013_07_Jul

The man page for cut lists "-b, --bytes=LIST" as the first described option.
man is your friend.



On Mon, Nov 07, 2016 at 07:47:41AM -0800, Rich Shepard wrote:
>    I tried using cut to list permissions and filenames from a directory
> listing, example:
> 
>    ls -l | cut -d"\b" -f 1,9 > temp.txt
> 
> but the delimiter is more than a single character. Using  -d " " for the
> delimiter does not work as there are more than a single space separating
> fields, and the white space is not uniformly a tab.
> 
>    The man page and results from my web searches haven't shown me how to
> correctly specify the delimiter.
> 
>    Here's an example listing from ~/;
> 
> $ ls -l | head
> 
> -rw-r--r--  1 rshepard users       14 Nov  5 08:30 CURRENTIP
> drwxrwxr-x  2 rshepard users     4096 Nov  8  2010 Desktop/
> drwx------  2 rshepard users     4096 Oct 18  2014 Downloads/
> drwx------  8 rshepard users     4096 Nov  7 05:39 Dropbox/
> drwxr-xr-x  2 rshepard users     4096 Jul  6 08:31 News/
> drwxrwxr-x 44 rshepard users     4096 Nov  4 10:47 R/
> -rw-r--r--  1 rshepard users  2569555 Oct 31 16:29 rue2009.pdf
> -rw-r--r--  1 rshepard users    14052 Dec  4  2015 UTF-8-demo.txt
> -rw-r--r--  1 rshepard users  1318075 Oct 25 10:16 al-rawas2011.pdf
> 
> and I want to extract fields 1 and 9.
> 
> TIA,
> 
> Rich
> 
> 
> _______________________________________________
> PLUG mailing list
> PLUG@lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
> 

-- 
      Michael Rasmussen, Portland Oregon  
    Be Appropriate && Follow Your Curiosity
Do something nice for someone, somewhere. We are all trying to make our
way in the world and kindness is never wasted.
    ~ Kent Peterson
_______________________________________________
PLUG mailing list
PLUG@lists.pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to