Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #159259 > unrolled thread
| Started by | "Alfred Charles Stockton" <alf@devacs.za.net> |
|---|---|
| First post | 2015-10-16 14:50 +0200 |
| Last post | 2015-10-17 03:40 +0200 |
| Articles | 10 — 10 participants |
Back to article view | Back to linux.debian.user
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Extract substring from cat "Alfred Charles Stockton" <alf@devacs.za.net> - 2015-10-16 14:50 +0200
Re: Extract substring from cat Nemeth Gyorgy <friczy@freemail.hu> - 2015-10-16 15:00 +0200
Re: Extract substring from cat <tomas@tuxteam.de> - 2015-10-16 15:50 +0200
Re: Extract substring from cat Kurt Flex <flxkrt@aol.com> - 2015-10-18 22:00 +0200
Re: Extract substring from cat tomas@tuxteam.de - 2015-10-18 22:10 +0200
Re: Extract substring from cat Darac Marjal <mailinglist@darac.org.uk> - 2015-10-16 15:10 +0200
Re: Extract substring from cat Santiago Vila <sanvila@unex.es> - 2015-10-16 15:30 +0200
Re: Extract substring from cat "John L. Cunningham" <djohngo@gmail.com> - 2015-10-16 15:30 +0200
Re: Extract substring from cat Jonathan <winelauncher.jonathan@googlemail.com> - 2015-10-17 01:40 +0200
Re: Extract substring from cat Cindy-Sue Causey <butterflybytes@gmail.com> - 2015-10-17 03:40 +0200
| From | "Alfred Charles Stockton" <alf@devacs.za.net> |
|---|---|
| Date | 2015-10-16 14:50 +0200 |
| Subject | Extract substring from cat |
| Message-ID | <qkcCm-6zl-7@gated-at.bofh.it> |
If I issue the command cat /etc/*-release on my Debian system I get:- PRETTY_NAME="Debian GNU/Linux 8 (jessie)" NAME="Debian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=debian HOME_URL="http://www.debian.org/" SUPPORT_URL="http://www.debian.org/support/" BUG_REPORT_URL="https://bugs.debian.org/" Now what I would like to do is to only print the substring "Debian GNU/Linux 8 (jessie)" from the 1st line, preferably in bash. Please tell me how I should go about this? -- Regards, Alf Stockton
[toc] | [next] | [standalone]
| From | Nemeth Gyorgy <friczy@freemail.hu> |
|---|---|
| Date | 2015-10-16 15:00 +0200 |
| Message-ID | <qkcM2-6LS-5@gated-at.bofh.it> |
| In reply to | #159259 |
2015-10-16 14:15 keltezéssel, Alfred Charles Stockton írta: > > If I issue the command cat /etc/*-release on my Debian system I get:- > > PRETTY_NAME="Debian GNU/Linux 8 (jessie)" > NAME="Debian GNU/Linux" > VERSION_ID="8" > VERSION="8 (jessie)" > ID=debian > HOME_URL="http://www.debian.org/" > SUPPORT_URL="http://www.debian.org/support/" > BUG_REPORT_URL="https://bugs.debian.org/" > > Now what I would like to do is to only print the substring "Debian > GNU/Linux 8 (jessie)" from the 1st line, preferably in bash. > > Please tell me how I should go about this? > > -- > Regards, > Alf Stockton > > > cat /etc/*-release | grep ^PRETTY_NAME | sed 's/^.*=//' -- --- Friczy --- 'Death is not a bug, it's a feature'
[toc] | [prev] | [next] | [standalone]
| From | <tomas@tuxteam.de> |
|---|---|
| Date | 2015-10-16 15:50 +0200 |
| Message-ID | <qkdyp-7XP-1@gated-at.bofh.it> |
| In reply to | #159260 |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Fri, Oct 16, 2015 at 02:54:25PM +0200, Nemeth Gyorgy wrote: > 2015-10-16 14:15 keltezéssel, Alfred Charles Stockton írta: > > > > If I issue the command cat /etc/*-release on my Debian system I get:- > > > > PRETTY_NAME="Debian GNU/Linux 8 (jessie)" > > NAME="Debian GNU/Linux" > > VERSION_ID="8" > > VERSION="8 (jessie)" > > ID=debian > > HOME_URL="http://www.debian.org/" > > SUPPORT_URL="http://www.debian.org/support/" > > BUG_REPORT_URL="https://bugs.debian.org/" > > > > Now what I would like to do is to only print the substring "Debian > > GNU/Linux 8 (jessie)" from the 1st line, preferably in bash. > > > > Please tell me how I should go about this? > > > > -- > > Regards, > > Alf Stockton > > > > > > > cat /etc/*-release | grep ^PRETTY_NAME | sed 's/^.*=//' Many insightful answers have been given. Yours is an example of "useless use of cat" [1], better spelt as grep ^PRETTY_NAME /etc/*-release | sed 's/^.*=//' Even better, since sed can do grep: sed -ne '/^PRETTY_NAME=/ s/^.*=// p' < /etc/*-release [1] <http://uselessuseofcat.com/> regards - -- t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlYg+DYACgkQBcgs9XrR2kYxKACdHFb8xn/cjQU5of0vsRmxnUXZ INAAnA3MxfnslHQPQ0Cw9TIOwWxcpI7F =xsvX -----END PGP SIGNATURE-----
[toc] | [prev] | [next] | [standalone]
| From | Kurt Flex <flxkrt@aol.com> |
|---|---|
| Date | 2015-10-18 22:00 +0200 |
| Message-ID | <ql2hA-6M1-7@gated-at.bofh.it> |
| In reply to | #159264 |
On Fri, Oct 16, 2015 at 03:14:31PM +0200, tomas@tuxteam.de wrote: > On Fri, Oct 16, 2015 at 02:54:25PM +0200, Nemeth Gyorgy wrote: > > 2015-10-16 14:15 keltezéssel, Alfred Charles Stockton írta: > > cat /etc/*-release | grep ^PRETTY_NAME | sed 's/^.*=//' > > Many insightful answers have been given. Yours is an example of "useless > use of cat" [1], better spelt as > > grep ^PRETTY_NAME /etc/*-release | sed 's/^.*=//' > > Even better, since sed can do grep: > > sed -ne '/^PRETTY_NAME=/ s/^.*=// p' < /etc/*-release Not if there may be more than one file matching the pattern. In that case at least your "better" example breaks. It can be fixed by omitting "<". Kurt
[toc] | [prev] | [next] | [standalone]
| From | tomas@tuxteam.de |
|---|---|
| Date | 2015-10-18 22:10 +0200 |
| Message-ID | <ql2rg-7dt-15@gated-at.bofh.it> |
| In reply to | #159409 |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sun, Oct 18, 2015 at 09:58:01PM +0200, Kurt Flex wrote: > On Fri, Oct 16, 2015 at 03:14:31PM +0200, tomas@tuxteam.de wrote: > > On Fri, Oct 16, 2015 at 02:54:25PM +0200, Nemeth Gyorgy wrote: > > > 2015-10-16 14:15 keltezéssel, Alfred Charles Stockton írta: > > > cat /etc/*-release | grep ^PRETTY_NAME | sed 's/^.*=//' > > > > Many insightful answers have been given. Yours is an example of "useless > > use of cat" [1], better spelt as > > > > grep ^PRETTY_NAME /etc/*-release | sed 's/^.*=//' > > > > Even better, since sed can do grep: > > > > sed -ne '/^PRETTY_NAME=/ s/^.*=// p' < /etc/*-release > > Not if there may be more than one file matching the pattern. In that > case at least your "better" example breaks. It can be fixed by > omitting "<". You are right, of course. Thanks :-) - -- tomás -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEUEARECAAYFAlYj8pwACgkQBcgs9XrR2kanlQCYsVXb2pIomOKeQaqCNTbEKrqZ dQCfSIKTynqVZCWbxKlfc6NL/AVBNvI= =I46h -----END PGP SIGNATURE-----
[toc] | [prev] | [next] | [standalone]
| From | Darac Marjal <mailinglist@darac.org.uk> |
|---|---|
| Date | 2015-10-16 15:10 +0200 |
| Message-ID | <qkcVJ-7cO-51@gated-at.bofh.it> |
| In reply to | #159259 |
[Multipart message — attachments visible in raw view] — view raw
On Fri, Oct 16, 2015 at 02:15:46PM +0200, Alfred Charles Stockton wrote: > > If I issue the command cat /etc/*-release on my Debian system I get:- > > PRETTY_NAME="Debian GNU/Linux 8 (jessie)" > NAME="Debian GNU/Linux" > VERSION_ID="8" > VERSION="8 (jessie)" > ID=debian > HOME_URL="http://www.debian.org/" > SUPPORT_URL="http://www.debian.org/support/" > BUG_REPORT_URL="https://bugs.debian.org/" > > Now what I would like to do is to only print the substring "Debian > GNU/Linux 8 (jessie)" from the 1st line, preferably in bash. > > Please tell me how I should go about this? The EASY way? "( source /etc/*-release; echo $PRETTY_NAME )". 'source' executes the commands in the file(s) which, in this case, are simple variable assignments. 'echo' prints the contents of one of those variables. Finally "( ... ; ... )" executes the two commands one after the other in a subshell. When the subshell exits (after the echo command), the variables will be forgotten. > > -- > Regards, > Alf Stockton > > -- For more information, please reread.
[toc] | [prev] | [next] | [standalone]
| From | Santiago Vila <sanvila@unex.es> |
|---|---|
| Date | 2015-10-16 15:30 +0200 |
| Message-ID | <qkdf5-7zE-33@gated-at.bofh.it> |
| In reply to | #159259 |
On Fri, Oct 16, 2015 at 02:15:46PM +0200, Alfred Charles Stockton wrote:
> Now what I would like to do is to only print the substring "Debian
> GNU/Linux 8 (jessie)" from the 1st line, preferably in bash.
The standard says /etc/os-release is shell-compatible, so I would do this:
. /etc/os-release
echo ${PRETTY_NAME}
[toc] | [prev] | [next] | [standalone]
| From | "John L. Cunningham" <djohngo@gmail.com> |
|---|---|
| Date | 2015-10-16 15:30 +0200 |
| Message-ID | <qkdf5-7zE-51@gated-at.bofh.it> |
| In reply to | #159259 |
On Fri, Oct 16, 2015 at 02:15:46PM +0200, Alfred Charles Stockton wrote:
>
> If I issue the command cat /etc/*-release on my Debian system I get:-
>
> PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
> NAME="Debian GNU/Linux"
> VERSION_ID="8"
> VERSION="8 (jessie)"
> ID=debian
> HOME_URL="http://www.debian.org/"
> SUPPORT_URL="http://www.debian.org/support/"
> BUG_REPORT_URL="https://bugs.debian.org/"
>
> Now what I would like to do is to only print the substring "Debian
> GNU/Linux 8 (jessie)" from the 1st line, preferably in bash.
>
> Please tell me how I should go about this?
$ gawk -F= '/^PRETTY/{ print $2 }' /etc/*-release
[toc] | [prev] | [next] | [standalone]
| From | Jonathan <winelauncher.jonathan@googlemail.com> |
|---|---|
| Date | 2015-10-17 01:40 +0200 |
| Message-ID | <qkmLo-4Eg-17@gated-at.bofh.it> |
| In reply to | #159259 |
On Fri, 16 Oct 2015 14:15:46 +0200 "Alfred Charles Stockton" <alf@devacs.za.net> wrote: > Now what I would like to do is to only print the substring "Debian > GNU/Linux 8 (jessie)" from the 1st line, preferably in bash. > > Please tell me how I should go about this? lsb_release -ds from lsb-release package.
[toc] | [prev] | [next] | [standalone]
| From | Cindy-Sue Causey <butterflybytes@gmail.com> |
|---|---|
| Date | 2015-10-17 03:40 +0200 |
| Message-ID | <qkoDv-7lZ-3@gated-at.bofh.it> |
| In reply to | #159287 |
On 10/16/15, Jonathan <winelauncher.jonathan@googlemail.com> wrote: > On Fri, 16 Oct 2015 14:15:46 +0200 > "Alfred Charles Stockton" <alf@devacs.za.net> wrote: > >> Now what I would like to do is to only print the substring "Debian >> GNU/Linux 8 (jessie)" from the 1st line, preferably in bash. >> >> Please tell me how I should go about this? > > lsb_release -ds > from lsb-release package. I've been partially playing along with this thread as it has evolved. I received 2 slightly different outputs regarding this latest.. $ lsb_release -ds $ Debian GNU/Linux unstable (sid) and... $ cat /etc/*-release $ PRETTY_NAME="Debian GNU/Linux stretch/sid" Unstable is certainly Sid's first, middle, and last name, grin. Stretch nicely defines where Sid is in a release cycle of the moment..... a nice little time stamp of sorts.... ish. :) Cindy :) -- Cindy-Sue Causey Talking Rock, Pickens County, Georgia, USA * runs with duct tape *
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web