Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #176395
| From | Floris <jkfloris@dds.nl> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | When do I use perl, awk, sed, grep, cut etc.. Was[OT] get all devices from a vendor from pci.ids |
| Date | 2017-01-06 22:50 +0100 |
| Message-ID | <sWKyD-7RC-41@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <sWjRL-5ZY-11@gated-at.bofh.it> <sWmwi-7Lg-31@gated-at.bofh.it> <sWmwi-7Lg-29@gated-at.bofh.it> <sWmFY-7Qg-41@gated-at.bofh.it> <sWKoW-7NO-35@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
>> So every Debian user has the perl command?
> Not only Debian users, the vast majority of linux / unix users have
> perl installed (maybe now that android is here, this statement is not
> true any more ...
>
> With awk:
> awk -v vendor=0e11 'p == 1 && /^[^[:space:]]/ { p=0; } $0 ~ "^"vendor"
> " {p=1;} p' /usr/share/misc/pci.ids
>
> With sed:
> sed -ne '/^0e11/p' -e '/^0e11/,/^[^[:space:]]/ { /^[^[:space:]]/d ; p
> }' /usr/share/misc/pci.ids
>
> Wrapping to script which get an argument is easy
>
> Regards
>
Thanks for your answer, and the next question pops in.
Is there a "rule" when I use perl, awk, sed, grep, cut etc. in a script?
Often I find multiple solutions on the Internet to achieve the same output.
A simple example:
cut -d: -f2
or
awk -F: '{ print $2 }'
Is the one better as the other (CPU/RAM usage), or is it just "taste"
Floris
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[OT] get all devices from a vendor from pci.ids Floris <jkfloris@dds.nl> - 2017-01-04 17:40 +0100
Re: [OT] get all devices from a vendor from pci.ids Floris <jkfloris@dds.nl> - 2017-01-05 18:10 +0100
Re: [OT] get all devices from a vendor from pci.ids Javier Barroso <javibarroso@gmail.com> - 2017-01-05 18:20 +0100
Re: [OT] get all devices from a vendor from pci.ids Nicolas George <george@nsup.org> - 2017-01-05 21:10 +0100
Re: [OT] get all devices from a vendor from pci.ids Floris <jkfloris@dds.nl> - 2017-01-05 21:20 +0100
Re: [OT] get all devices from a vendor from pci.ids Javier Barroso <javibarroso@gmail.com> - 2017-01-06 22:40 +0100
When do I use perl, awk, sed, grep, cut etc.. Was[OT] get all devices from a vendor from pci.ids Floris <jkfloris@dds.nl> - 2017-01-06 22:50 +0100
Re: When do I use perl, awk, sed, grep, cut etc.. Was[OT] get all devices from a vendor from pci.ids Javier Barroso <javibarroso@gmail.com> - 2017-01-06 23:50 +0100
Re: [OT] get all devices from a vendor from pci.ids Floris <jkfloris@dds.nl> - 2017-01-05 21:10 +0100
csiph-web