[PLUG] Specifying white space as delimiter for 'cut'

Larry Brigman larry.brigman at gmail.com
Mon Nov 7 16:01:31 UTC 2016


Woops extra $ in the script.
ls -l | awk '{print $1 $NF;}'


On Mon, Nov 7, 2016 at 8:00 AM, Larry Brigman <larry.brigman at gmail.com>
wrote:

> Try using awk
> ls -l | awk '{print $1 $$NF;}'
>
> Note if the file timestamp (creation or modification) is over a year old
> it changes and the output may not have 9 columns then.
>
> On Mon, Nov 7, 2016 at 7:47 AM, Rich Shepard <rshepard at appl-ecosys.com>
> 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 at lists.pdxlinux.org
>> http://lists.pdxlinux.org/mailman/listinfo/plug
>>
>
>



More information about the PLUG mailing list