Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #197286 > unrolled thread

Editing a piped in stream?

Started byRichard Owlett <rowlett@cloud85.net>
First post2018-07-06 18:20 +0200
Last post2018-07-09 20:50 +0200
Articles 20 on this page of 24 — 12 participants

Back to article view | Back to linux.debian.user


Contents

  Editing a piped in stream? Richard Owlett <rowlett@cloud85.net> - 2018-07-06 18:20 +0200
    Re: Editing a piped in stream? Michael Wagner <wagner_m_bremen@web.de> - 2018-07-06 18:50 +0200
      Re: Editing a piped in stream? Richard Owlett <rowlett@cloud85.net> - 2018-07-06 20:30 +0200
    Re: Editing a piped in stream? john doe <johndoe65534@mail.com> - 2018-07-06 19:10 +0200
    Re: Editing a piped in stream? David Christensen <dpchrist@holgerdanske.com> - 2018-07-07 04:10 +0200
      Re: Editing a piped in stream? John Crawley <john@bunsenlabs.org> - 2018-07-07 11:00 +0200
        Re: Editing a piped in stream? David Christensen <dpchrist@holgerdanske.com> - 2018-07-07 21:40 +0200
          Re: Editing a piped in stream? David Wright <deblis@lionunicorn.co.uk> - 2018-07-08 03:40 +0200
            Eureka;/ Re: Editing a piped in stream? Richard Owlett <rowlett@cloud85.net> - 2018-07-08 13:00 +0200
          Re: Editing a piped in stream? John Crawley <john@bunsenlabs.org> - 2018-07-08 03:40 +0200
            Re: Editing a piped in stream? john doe <johndoe65534@mail.com> - 2018-07-08 07:40 +0200
              Re: Editing a piped in stream? Andy Smith <andy@strugglers.net> - 2018-07-08 13:20 +0200
                Re: Editing a piped in stream? Richard Owlett <rowlett@cloud85.net> - 2018-07-08 15:20 +0200
                  Re: Editing a piped in stream? Richard Owlett <rowlett@cloud85.net> - 2018-07-08 16:00 +0200
                    Re: Editing a piped in stream? John Darrah <xyllyx@gmail.com> - 2018-07-08 18:50 +0200
                      Re: Editing a piped in stream? mick crane <mick.crane@gmail.com> - 2018-07-10 14:20 +0200
                        Re: Editing a piped in stream? Greg Wooledge <wooledg@eeg.ccf.org> - 2018-07-10 14:40 +0200
                          Re: Editing a piped in stream? mick crane <mick.crane@gmail.com> - 2018-07-10 15:00 +0200
                        Re: Editing a piped in stream? john doe <johndoe65534@mail.com> - 2018-07-10 15:30 +0200
                Re: Editing a piped in stream? mick crane <mick.crane@gmail.com> - 2018-07-10 14:50 +0200
              Re: Editing a piped in stream? Greg Wooledge <wooledg@eeg.ccf.org> - 2018-07-09 14:50 +0200
                Re: Nvidia drivers Matthew Crews <mattcrews@mattcrews.com> - 2018-07-09 15:20 +0200
                  Re: Nvidia drivers Matthew Crews <mattcrews@mattcrews.com> - 2018-07-09 20:40 +0200
                    Re: Nvidia drivers Boyan Penkov <boyan.penkov@gmail.com> - 2018-07-09 20:50 +0200

Page 1 of 2  [1] 2  Next page →


#197286 — Editing a piped in stream?

FromRichard Owlett <rowlett@cloud85.net>
Date2018-07-06 18:20 +0200
SubjectEditing a piped in stream?
Message-ID<w8BCG-5u7-11@gated-at.bofh.it>
Subject line is poorly phrased.
While working on a problem {solved by a different approach} I had:
    ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' data.txt
I would then manually edit data.txt by replacing the space character 
between the two fields with a tab.

I suspect I should be able to do:
    ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' | *something* > 
prettydata.txt

I searched for examples/tutorials found that it should be conceptually 
possible. However the examples I found were processing streams I didn't 
understand.

What should I be looking for?
TIA

[toc] | [next] | [standalone]


#197287

FromMichael Wagner <wagner_m_bremen@web.de>
Date2018-07-06 18:50 +0200
Message-ID<w8C5H-5DK-1@gated-at.bofh.it>
In reply to#197286

[Multipart message — attachments visible in raw view] — view raw

On Jul 06, 2018 um 11:17:56, Richard Owlett wrote:
> Subject line is poorly phrased.
> While working on a problem {solved by a different approach} I had:
>    ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' data.txt
> I would then manually edit data.txt by replacing the space character between
> the two fields with a tab.
> 
> I suspect I should be able to do:
>    ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' | *something* >
> prettydata.txt
> 
> I searched for examples/tutorials found that it should be conceptually
> possible. However the examples I found were processing streams I didn't
> understand.

Hello Richard,

one way is to do it with sed:

ls -l /dev/disk/by-label/|cut -f 10,12 -d ' '|sed 's/ /\t/g'>prettydata.txt

Hth Michael

[toc] | [prev] | [next] | [standalone]


#197291

FromRichard Owlett <rowlett@cloud85.net>
Date2018-07-06 20:30 +0200
Message-ID<w8DEt-6FH-1@gated-at.bofh.it>
In reply to#197287
On 07/06/2018 11:46 AM, Michael Wagner wrote:
> On Jul 06, 2018 um 11:17:56, Richard Owlett wrote:
>> Subject line is poorly phrased.
>> While working on a problem {solved by a different approach} I had:
>>     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' data.txt
>> I would then manually edit data.txt by replacing the space character between
>> the two fields with a tab.
>>
>> I suspect I should be able to do:
>>     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' | *something* >
>> prettydata.txt
>>
>> I searched for examples/tutorials found that it should be conceptually
>> possible. However the examples I found were processing streams I didn't
>> understand.
> 
> Hello Richard,
> 
> one way is to do it with sed:
> 
> ls -l /dev/disk/by-label/|cut -f 10,12 -d ' '|sed 's/ /\t/g'>prettydata.txt
> 
> Hth Michael
> 

Thank you.
https://www.gnu.org/software/sed/manual/sed.html makes interesting reading.

[toc] | [prev] | [next] | [standalone]


#197289

Fromjohn doe <johndoe65534@mail.com>
Date2018-07-06 19:10 +0200
Message-ID<w8Cp3-60h-3@gated-at.bofh.it>
In reply to#197286
On 7/6/2018 6:17 PM, Richard Owlett wrote:
> Subject line is poorly phrased.
> While working on a problem {solved by a different approach} I had:
>     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' data.txt
> I would then manually edit data.txt by replacing the space character 
> between the two fields with a tab.
> 

What is your original output and what is the desired output?

-- 
John Doe

[toc] | [prev] | [next] | [standalone]


#197301

FromDavid Christensen <dpchrist@holgerdanske.com>
Date2018-07-07 04:10 +0200
Message-ID<w8KPD-2CT-1@gated-at.bofh.it>
In reply to#197286
On 07/06/18 09:17, Richard Owlett wrote:
> Subject line is poorly phrased.
> While working on a problem {solved by a different approach} I had:
>     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' data.txt
> I would then manually edit data.txt by replacing the space character 
> between the two fields with a tab.

I assume you meant:

     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' > data.txt


(It is best to cut and paste from a console session, rather than typing 
untested commands and/or output into a post.)


> I suspect I should be able to do:
>     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' | *something* > 
> prettydata.txt
> 
> I searched for examples/tutorials found that it should be conceptually 
> possible. However the examples I found were processing streams I didn't 
> understand.
> 
> What should I be looking for?

Beware that ls(1) with the -l option can produce output with a variable 
number of spaces between fields:

2018-07-06 18:51:53 dpchrist@po ~
$ ls -l /bin/e*
-rwxr-xr-x 1 root root 31464 Feb 22  2017 /bin/echo
-rwxr-xr-x 1 root root    28 Jan 23  2017 /bin/egrep


When you feed that to cut(1) and change the delimiter to a space, the 
result is broken (and impossible to fix?) because cut(1) expects exactly 
one delimiter between each field:

2018-07-06 18:52:27 dpchrist@po ~
$ ls -l /bin/e* | cut -f 6,7,9 -d ' '
Feb 22 2017
   Jan


What you want is a tool that can handle fields delimited by one or more 
whitespace characters.  Regular expressions come to mind, but RTFM 
cut(1) doesn't look promising:

2018-07-06 18:53:45 dpchrist@po ~
$ ls -l /bin/e* | cut -f 6,7,9 -d '\s+'
cut: the delimiter must be a single character
Try 'cut --help' for more information.


Perhaps awk(1) or sed(1) (?).


Perl with the -a (autosplit) and -e (evaluate) options is ideal in this 
situation, replacing both cut(1) and "something":

2018-07-06 18:55:29 dpchrist@po ~
$ ls -l /bin/e* | perl -ae 'print join("\t", @F[5,6,7]), "\n"'
Feb	22	2017
Jan	23	2017


Perhaps other people will post solutions in their favorite scripting/ 
programming language.  These give you more power and control than 
traditional shell pipelines and command-line tools.  You should consider 
learning one.


David

[toc] | [prev] | [next] | [standalone]


#197310

FromJohn Crawley <john@bunsenlabs.org>
Date2018-07-07 11:00 +0200
Message-ID<w8Rep-6f8-1@gated-at.bofh.it>
In reply to#197301
On 2018-07-07 11:02, David Christensen wrote:
> On 07/06/18 09:17, Richard Owlett wrote:
>> Subject line is poorly phrased.
>> While working on a problem {solved by a different approach} I had:
>>     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' data.txt
>> I would then manually edit data.txt by replacing the space character 
>> between the two fields with a tab.
>> I suspect I should be able to do:
>>     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' | *something* > 
>> prettydata.txt
> What you want is a tool that can handle fields delimited by one or more 
> whitespace characters.  Regular expressions come to mind, but RTFM 
> cut(1) doesn't look promising:

> Perhaps awk(1) or sed(1) (?).

awk is indeed one alternative, it accepts multi-spaces between fields:
ls -l /dev/disk/by-label/ | awk '/total/{next};{print $9"\t"$11}' > 
prettydata.txt

Ideal would be a more focussed way of reading out the disk info, perhaps 
something with blkid or lsblk?

-- 
John

[toc] | [prev] | [next] | [standalone]


#197325

FromDavid Christensen <dpchrist@holgerdanske.com>
Date2018-07-07 21:40 +0200
Message-ID<w91dM-3T1-13@gated-at.bofh.it>
In reply to#197310
On 07/07/18 01:51, John Crawley wrote:
> On 2018-07-07 11:02, David Christensen wrote:
>> On 07/06/18 09:17, Richard Owlett wrote:
>>> Subject line is poorly phrased.
>>> While working on a problem {solved by a different approach} I had:
>>>     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' data.txt
>>> I would then manually edit data.txt by replacing the space character 
>>> between the two fields with a tab.
>>> I suspect I should be able to do:
>>>     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' | *something* > 
>>> prettydata.txt
>> What you want is a tool that can handle fields delimited by one or 
>> more whitespace characters.  Regular expressions come to mind, but 
>> RTFM cut(1) doesn't look promising:
> 
>> Perhaps awk(1) or sed(1) (?).
> 
> awk is indeed one alternative, it accepts multi-spaces between fields:
> ls -l /dev/disk/by-label/ | awk '/total/{next};{print $9"\t"$11}' > 
> prettydata.txt

Thank you for posting an Awk solution.  Continuing my example:

2018-07-07 12:20:30 dpchrist@po ~
$ ls -l /bin/e* | awk '/total/{next};{print $6"\t"$7"\t"$8}'
Feb	22	2017
Jan	23	2017


> Ideal would be a more focussed way of reading out the disk info, perhaps 
> something with blkid or lsblk?

I don't follow.  blkid(8) and lsblk(8) would be ideal for what purpose? 
Using what metric?


David

[toc] | [prev] | [next] | [standalone]


#197331

FromDavid Wright <deblis@lionunicorn.co.uk>
Date2018-07-08 03:40 +0200
Message-ID<w96Q9-7h0-1@gated-at.bofh.it>
In reply to#197325
On Sat 07 Jul 2018 at 12:35:02 (-0700), David Christensen wrote:
> On 07/07/18 01:51, John Crawley wrote:
> >On 2018-07-07 11:02, David Christensen wrote:
> >>On 07/06/18 09:17, Richard Owlett wrote:
> >>>Subject line is poorly phrased.
> >>>While working on a problem {solved by a different approach} I had:
> >>>    ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' data.txt
> >>>I would then manually edit data.txt by replacing the space
> >>>character between the two fields with a tab.
> >>>I suspect I should be able to do:
> >>>    ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' |
> >>>*something* > prettydata.txt
> >>What you want is a tool that can handle fields delimited by one
> >>or more whitespace characters.  Regular expressions come to
> >>mind, but RTFM cut(1) doesn't look promising:
> >
> >>Perhaps awk(1) or sed(1) (?).
> >
> >awk is indeed one alternative, it accepts multi-spaces between fields:
> >ls -l /dev/disk/by-label/ | awk '/total/{next};{print $9"\t"$11}'
> >> prettydata.txt
> 
> Thank you for posting an Awk solution.  Continuing my example:
> 
> 2018-07-07 12:20:30 dpchrist@po ~
> $ ls -l /bin/e* | awk '/total/{next};{print $6"\t"$7"\t"$8}'
> Feb	22	2017
> Jan	23	2017
> 
> 
> >Ideal would be a more focussed way of reading out the disk info,
> >perhaps something with blkid or lsblk?
> 
> I don't follow.  blkid(8) and lsblk(8) would be ideal for what
> purpose? Using what metric?

One might assume the OP wants something like

$ lsblk -l -o NAME,LABEL,MOUNTPOINT
NAME     LABEL       MOUNTPOINT
sda                  
sda2     SYSTEM_DRV  
sda3     LRS_ESP     
sda4                 
sda6     swan06      /
sda7     swan07      /wrenbk
sda10    swan10      [SWAP]
swanhome             /home
$ 

or whichever two columns are of interest.
(Just a selection of the output lines here.)

Cheers,
David.

[toc] | [prev] | [next] | [standalone]


#197341 — Eureka;/ Re: Editing a piped in stream?

FromRichard Owlett <rowlett@cloud85.net>
Date2018-07-08 13:00 +0200
SubjectEureka;/ Re: Editing a piped in stream?
Message-ID<w9fA5-4aU-3@gated-at.bofh.it>
In reply to#197331
On 07/07/2018 08:33 PM, David Wright wrote:
>
>>>> On 07/06/18 09:17, Richard Owlett wrote:
>>>>> Subject line is poorly phrased.
>>>>> While working on a problem {solved by a different approach} I had:
>>>>>      ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' > data.txt
>>>>> I would then manually edit data.txt by replacing the space
>>>>> character between the two fields with a tab.
>>>>> I suspect I should be able to do:
>>>>>      ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' |
>>>>> *something* > prettydata.txt
>>>> What you want is a tool that can handle fields delimited by one
>>>> or more whitespace characters.  Regular expressions come to
>>>> mind, but RTFM cut(1) doesn't look promising:
>>>  [snip]
> 
> One might assume the OP wants something like
> 
> $ lsblk -l -o NAME,LABEL,MOUNTPOINT
> NAME     LABEL       MOUNTPOINT
> sda
> sda2     SYSTEM_DRV
> sda3     LRS_ESP
> sda4
> sda6     swan06      /
> sda7     swan07      /wrenbk
> sda10    swan10      [SWAP]
> swanhome             /home
> 

One might assume correctly :!
It even pretty prints the way I prefer.
That it can be sorted on a column is a bonus.
*THANK YOU*

[toc] | [prev] | [next] | [standalone]


#197332

FromJohn Crawley <john@bunsenlabs.org>
Date2018-07-08 03:40 +0200
Message-ID<w96Qa-7h0-3@gated-at.bofh.it>
In reply to#197325
On 2018-07-08 04:35, David Christensen wrote:
> On 07/07/18 01:51, John Crawley wrote:
>> On 2018-07-07 11:02, David Christensen wrote:
>>> On 07/06/18 09:17, Richard Owlett wrote:
>>>> While working on a problem {solved by a different approach} I had:
>>>>     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' data.txt
>>>> I would then manually edit data.txt by replacing the space character 
>>>> between the two fields with a tab.
>>>> I suspect I should be able to do:
>>>>     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' | *something* > 
>>>> prettydata.txt
> 
>> Ideal would be a more focussed way of reading out the disk info, 
>> perhaps something with blkid or lsblk?
> 
> I don't follow.  blkid(8) and lsblk(8) would be ideal for what purpose? 
> Using what metric?

I meant that there might be a utility that would output the disk info 
directly, avoiding the need to do any post-processing with cut, sed, awk 
and friends, and suggested blkid and lsblk as possible candidates.

Just a suggestion I threw out for those with the time and motivation to 
plough though the man pages.

-- 
John

[toc] | [prev] | [next] | [standalone]


#197339

Fromjohn doe <johndoe65534@mail.com>
Date2018-07-08 07:40 +0200
Message-ID<w9aAp-1c5-1@gated-at.bofh.it>
In reply to#197332
On 7/8/2018 3:38 AM, John Crawley wrote:
> On 2018-07-08 04:35, David Christensen wrote:
>> On 07/07/18 01:51, John Crawley wrote:
>>> On 2018-07-07 11:02, David Christensen wrote:
>>>> On 07/06/18 09:17, Richard Owlett wrote:
>>>>> While working on a problem {solved by a different approach} I had:
>>>>>     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' data.txt
>>>>> I would then manually edit data.txt by replacing the space 
>>>>> character between the two fields with a tab.
>>>>> I suspect I should be able to do:
>>>>>     ls -l /dev/disk/by-label/ | cut -f 10,12 -d ' ' | *something* > 
>>>>> prettydata.txt
>>
>>> Ideal would be a more focussed way of reading out the disk info, 
>>> perhaps something with blkid or lsblk?
>>
>> I don't follow.  blkid(8) and lsblk(8) would be ideal for what 
>> purpose? Using what metric?
> 
> I meant that there might be a utility that would output the disk info 
> directly, avoiding the need to do any post-processing with cut, sed, awk 
> and friends, and suggested blkid and lsblk as possible candidates.
> 
> Just a suggestion I threw out for those with the time and motivation to 
> plough though the man pages.
> 

The issue here is that we don't know what the OP wants (original and 
desired output)!!! :)

There is probably a better solution that  the one of using multiples pipes.

-- 
John Doe

[toc] | [prev] | [next] | [standalone]


#197342

FromAndy Smith <andy@strugglers.net>
Date2018-07-08 13:20 +0200
Message-ID<w9fTr-4wX-11@gated-at.bofh.it>
In reply to#197339
Hello,

On Sun, Jul 08, 2018 at 07:39:07AM +0200, john doe wrote:
> The issue here is that we don't know what the OP wants

A situation sadly familiar when dealing with this particular
poster's threads.

Also in the general case, if you ever find yourself parsing the
output of "ls", you will probably find that there is a better way to
be doing what you're trying to do. There are a lot of issues with
parsing "ls" output:

    <http://mywiki.wooledge.org/ParsingLs>
    <https://unix.stackexchange.com/questions/128985/why-not-parse-ls>

Cheers,
Andy

[toc] | [prev] | [next] | [standalone]


#197345

FromRichard Owlett <rowlett@cloud85.net>
Date2018-07-08 15:20 +0200
Message-ID<w9hLA-5Dt-11@gated-at.bofh.it>
In reply to#197342
On 07/08/2018 06:18 AM, Andy Smith wrote:
> Hello,
> 
> On Sun, Jul 08, 2018 at 07:39:07AM +0200, john doe wrote:
>> The issue here is that we don't know what the OP wants
> 
> A situation sadly familiar when dealing with this particular
> poster's threads.
> 
> Also in the general case, if you ever find yourself parsing the
> output of "ls", you will probably find that there is a better way to
> be doing what you're trying to do. There are a lot of issues with
> parsing "ls" output:
> 
>      <http://mywiki.wooledge.org/ParsingLs>
>      <https://unix.stackexchange.com/questions/128985/why-not-parse-ls>

Sometimes I just can't win {<grin>/<groan>/??? ;}
In some threads I'm chided for lack of details.
In this and other threads I lose for giving too many.

Y'all will have admit that I did say "Subject line is poorly phrased."
Having read the responses, my subject line my not be all that bad.

A better subject/body might have been [How does one edit a piped in 
stream?] .
I'll lay odds that I would be asked for more details.
If I can't win, can I break even? <*chuckle*>
Thanks

[toc] | [prev] | [next] | [standalone]


#197346

FromRichard Owlett <rowlett@cloud85.net>
Date2018-07-08 16:00 +0200
Message-ID<w9ioh-5Qg-5@gated-at.bofh.it>
In reply to#197345
On 07/08/2018 08:12 AM, Richard Owlett wrote:
> [snip]
> In some threads I'm chided for lack of details.
> In this and other threads I lose for giving too many.
> 
> Y'all will have admit that I did say "Subject line is poorly phrased."
> Having read the responses, my subject line my not be all that bad.
> 
> A better subject/body might have been [How does one edit a piped in 
> stream?] .
> I'll lay odds that I would be asked for more details.


A philosophically good answer to that phrasing might be:

https://duckduckgo.com/html?q=%2B%22sed%22%20%2B%22awk%22%20%2B%22stream%22%20%2B%22tutorial%22

Until this thread I didn't have concept of "stream editor", much less 
the existence of "sed".
I had heard of "AWK", but had an image of it being a regex parser.

[toc] | [prev] | [next] | [standalone]


#197355

FromJohn Darrah <xyllyx@gmail.com>
Date2018-07-08 18:50 +0200
Message-ID<w9l2N-7v2-1@gated-at.bofh.it>
In reply to#197346
On 7/8/2018 7:00 AM, Richard Owlett wrote:
>
> Until this thread I didn't have concept of "stream editor", much less 
> the existence of "sed".
> I had heard of "AWK", but had an image of it being a regex parser.
>
Awk is easy to learn because it is a minimal language. It can do 
anything sed can do and much more. I am always surprised that so many 
people opt to build long commands with cut/sed instead of using awk. 
FWIW, I use mawk because it is orders of magnitude faster than gawk.

-- john

[toc] | [prev] | [next] | [standalone]


#197432

Frommick crane <mick.crane@gmail.com>
Date2018-07-10 14:20 +0200
Message-ID<w9ZMB-6Mt-7@gated-at.bofh.it>
In reply to#197355
On 2018-07-08 17:41, John Darrah wrote:
> On 7/8/2018 7:00 AM, Richard Owlett wrote:
>> 
>> Until this thread I didn't have concept of "stream editor", much less 
>> the existence of "sed".
>> I had heard of "AWK", but had an image of it being a regex parser.
>> 
> Awk is easy to learn because it is a minimal language. It can do
> anything sed can do and much more. I am always surprised that so many
> people opt to build long commands with cut/sed instead of using awk.
> FWIW, I use mawk because it is orders of magnitude faster than gawk.
> 
> -- john


I'd like to learn some awk having found it handy once.
apt says mawk is installed

in /usr/bin I have
lrwxrwxrwx  1 root root         21 Apr  2 22:29 awk -> 
/etc/alternatives/awk
-rwxr-xr-x  1 root root     658072 Jan 25 12:55 gawk
-rwxr-xr-x  1 root root       3189 Jan 25 12:55 igawk
-rwxr-xr-x  1 root root     121976 Mar 23  2012 mawk
lrwxrwxrwx  1 root root         22 Apr  2 22:29 nawk -> 
/etc/alternatives/nawk

"awk" returns options for gawk and "mawk does nothing ( back to prompt)

In /etc/alternatives there is
awk
awk.1.gz
nawk
nawk.1.gz

how to run mawk ?


mick



-- 
Key ID    4BFEBB31

[toc] | [prev] | [next] | [standalone]


#197433

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2018-07-10 14:40 +0200
Message-ID<wa05X-6SX-9@gated-at.bofh.it>
In reply to#197432
On Tue, Jul 10, 2018 at 01:16:09PM +0100, mick crane wrote:
> I'd like to learn some awk having found it handy once.
> apt says mawk is installed
> 
> in /usr/bin I have
> lrwxrwxrwx  1 root root         21 Apr  2 22:29 awk -> /etc/alternatives/awk
> -rwxr-xr-x  1 root root     658072 Jan 25 12:55 gawk
> -rwxr-xr-x  1 root root       3189 Jan 25 12:55 igawk
> -rwxr-xr-x  1 root root     121976 Mar 23  2012 mawk
> lrwxrwxrwx  1 root root         22 Apr  2 22:29 nawk ->
> /etc/alternatives/nawk
> 
> "awk" returns options for gawk and "mawk does nothing ( back to prompt)

So, what's the problem?

> how to run mawk ?

mawk

You have already run it once, with no arguments, and it did nothing.
Now try giving it some arguments.

wooledg:~$ mawk -v foo=bar 'BEGIN {print foo}'
bar

See, just like awk.

[toc] | [prev] | [next] | [standalone]


#197436

Frommick crane <mick.crane@gmail.com>
Date2018-07-10 15:00 +0200
Message-ID<wa0pj-6Zl-7@gated-at.bofh.it>
In reply to#197433
On 2018-07-10 13:31, Greg Wooledge wrote:
> On Tue, Jul 10, 2018 at 01:16:09PM +0100, mick crane wrote:
>> I'd like to learn some awk having found it handy once.
>> apt says mawk is installed
>> 
>> in /usr/bin I have
>> lrwxrwxrwx  1 root root         21 Apr  2 22:29 awk -> 
>> /etc/alternatives/awk
>> -rwxr-xr-x  1 root root     658072 Jan 25 12:55 gawk
>> -rwxr-xr-x  1 root root       3189 Jan 25 12:55 igawk
>> -rwxr-xr-x  1 root root     121976 Mar 23  2012 mawk
>> lrwxrwxrwx  1 root root         22 Apr  2 22:29 nawk ->
>> /etc/alternatives/nawk
>> 
>> "awk" returns options for gawk and "mawk does nothing ( back to 
>> prompt)
> 
> So, what's the problem?
> 
>> how to run mawk ?
> 
> mawk
> 
> You have already run it once, with no arguments, and it did nothing.
> Now try giving it some arguments.
> 
> wooledg:~$ mawk -v foo=bar 'BEGIN {print foo}'
> bar
> 
> See, just like awk.

OK
mick
-- 
Key ID    4BFEBB31

[toc] | [prev] | [next] | [standalone]


#197438

Fromjohn doe <johndoe65534@mail.com>
Date2018-07-10 15:30 +0200
Message-ID<wa0Sl-7nX-3@gated-at.bofh.it>
In reply to#197432
On 7/10/2018 2:16 PM, mick crane wrote:
> On 2018-07-08 17:41, John Darrah wrote:
>> On 7/8/2018 7:00 AM, Richard Owlett wrote:
>>>
>>> Until this thread I didn't have concept of "stream editor", much less 
>>> the existence of "sed".
>>> I had heard of "AWK", but had an image of it being a regex parser.
>>>
>> Awk is easy to learn because it is a minimal language. It can do
>> anything sed can do and much more. I am always surprised that so many
>> people opt to build long commands with cut/sed instead of using awk.
>> FWIW, I use mawk because it is orders of magnitude faster than gawk.
>>
>> -- john
> 
> 
> I'd like to learn some awk having found it handy once.
> apt says mawk is installed
> 
> in /usr/bin I have
> lrwxrwxrwx  1 root root         21 Apr  2 22:29 awk -> 
> /etc/alternatives/awk
> -rwxr-xr-x  1 root root     658072 Jan 25 12:55 gawk
> -rwxr-xr-x  1 root root       3189 Jan 25 12:55 igawk
> -rwxr-xr-x  1 root root     121976 Mar 23  2012 mawk
> lrwxrwxrwx  1 root root         22 Apr  2 22:29 nawk -> 
> /etc/alternatives/nawk
> 
> "awk" returns options for gawk and "mawk does nothing ( back to prompt)
> 

At the end of those 'gawk' options:

"gawk is a pattern scanning and processing language.
By default it reads standard input and writes standard output."

$ printf "%s" "123 456 789" | awk '{print $2}'
456

-- 
John Doe

[toc] | [prev] | [next] | [standalone]


#197435

Frommick crane <mick.crane@gmail.com>
Date2018-07-10 14:50 +0200
Message-ID<wa0fE-6W7-3@gated-at.bofh.it>
In reply to#197342
On 2018-07-08 12:18, Andy Smith wrote:
> Hello,
> 
> On Sun, Jul 08, 2018 at 07:39:07AM +0200, john doe wrote:
>> The issue here is that we don't know what the OP wants
> 
> A situation sadly familiar when dealing with this particular
> poster's threads.
> 
> Also in the general case, if you ever find yourself parsing the
> output of "ls", you will probably find that there is a better way to
> be doing what you're trying to do. There are a lot of issues with
> parsing "ls" output:
> 
>     <http://mywiki.wooledge.org/ParsingLs>
>     <https://unix.stackexchange.com/questions/128985/why-not-parse-ls>
> 
> Cheers,
> Andy

about 10 years ago on another mailing list there was a guy who claimed 
to be dyslexic who said was uncertain of things but once you'd 
deciphered the jumble of words was asking quite complicated networking 
questions and would come back with a knowledgeable other question ( once 
you'd deciphered it ) I did think it might be a wind up.

mick

-- 
Key ID    4BFEBB31

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | linux.debian.user


csiph-web