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

2016-11-07 Thread Martin A. Brown
Hello there, > 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

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

2016-11-07 Thread Rich Shepard
On Mon, 7 Nov 2016, Michael Rasmussen wrote: > 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 | cut -b1-10,53- > The man page for cut lists "-b, --bytes=LIST" as the first described

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

2016-11-07 Thread Rich Shepard
On Mon, 7 Nov 2016, Larry Brigman wrote: > Looking at the info on cut, you cannot do it in a single command. You > would need to use sed. or tr with a pipe Thanks, Larry. I thought that cut needed a consistent delimiter but thought it might accommodate any whitespace defined by a single

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

2016-11-07 Thread Michael Rasmussen
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

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

2016-11-07 Thread Larry Brigman
Looking at the info on cut, you cannot do it in a single command. You would need to use sed. or tr with a pipe On Mon, Nov 7, 2016 at 8:01 AM, Larry Brigman wrote: > Woops extra $ in the script. > ls -l | awk '{print $1 $NF;}' > > > On Mon, Nov 7, 2016 at 8:00 AM,

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

2016-11-07 Thread Larry Brigman
Woops extra $ in the script. ls -l | awk '{print $1 $NF;}' On Mon, Nov 7, 2016 at 8:00 AM, Larry Brigman 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

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

2016-11-07 Thread brooks
Try this: ls -la | awk '{print $1, $9}' On Mon, 7 Nov 2016, 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 >

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

2016-11-07 Thread Larry Brigman
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 wrote: >I tried using cut to list permissions

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

2016-11-07 Thread Rich Shepard
On Mon, 7 Nov 2016, bro...@netgate.net wrote: > Try this: > ls -la | awk '{print $1, $9}' Brooks, Yes, awk will do the job. I wanted to learn if cut could also be used with a variable delimiter. Thanks, Rich ___ PLUG mailing list

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

2016-11-07 Thread Rich Shepard
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