[PLUG] Specifying white space as delimiter for 'cut'
Rich Shepard
rshepard at appl-ecosys.com
Mon Nov 7 15:47:41 UTC 2016
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
More information about the PLUG
mailing list