[opensuse] shell script help
Anyone know a good source of examples for dweebs who can't remember from one scripting writing session to the next anything new learned to get a task done, and requires examples rather than reading man pages to understand anything unfamiliar? I have a script containing among other things the following: grep 'using VT' /var/log/Xorg.0.log head -n7 /var/log/Xorg.0.log grep Output /var/log/Xorg.0.log | egrep -v 'disconnected|no monitor' This works fine as long as it's run on a default X session, but not otherwise. I need to substitute for each "0" in the above strings the value of the actual display in use, which happens to be the last of the two visible characters of $DISPLAY. I tried to figure out if I could somehow apply the cut command to $DISPLAY, but got nowhere via its man page. Is what I want to do a for loop task? Can anyone here help with this seemingly simple goal? -- "The wise are known for their understanding, and pleasant words are persuasive." Proverbs 16:21 (New Living Translation) Team OS/2 ** Reg. Linux User #211409 ** a11y rocks! Felix Miata *** http://fm.no-ip.com/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sun, 07 Jul 2013 21:09:22 -0400 Felix Miata <mrmazda@earthlink.net> wrote:
Anyone know a good source of examples for dweebs who can't remember from one scripting writing session to the next anything new learned to get a task done, and requires examples rather than reading man pages to understand anything unfamiliar?
I have a script containing among other things the following:
grep 'using VT' /var/log/Xorg.0.log head -n7 /var/log/Xorg.0.log grep Output /var/log/Xorg.0.log | egrep -v 'disconnected|no monitor'
This works fine as long as it's run on a default X session, but not otherwise. I need to substitute for each "0" in the above strings the value of the actual display in use, which happens to be the last of the two visible characters of $DISPLAY. I tried to figure out if I could somehow apply the cut command to $DISPLAY, but got nowhere via its man page. Is what I want to do a for loop task? Can anyone here help with this seemingly simple goal?
Hi Felix, "Learning the Bash shell" from O'Reilly (www.oreilly.com). Some of the examples are a bit weak but basics thoroughly covered. Tom KG7CFC -- "We could certainly slow the aging process down if it had to work its way through Congress". - Will Rogers ^^ --... ...-- / -.- --. --... -.-. ..-. -.-. ^^^^ Tom Taylor - retired penguin - KG7CFC AMD Phenom II x4 955 -- 4GB RAM -- 2x1.5TB sata2 openSUSE 12.3-x86_64 KDE 4.10.00, FF 19.0, claws-mail 3.9.1 registered linux user 263467 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iQEcBAEBAgAGBQJRWnjBAAoJEHjxEe80vkwITlwIAPb2aBryi1pBNtlTTL87E1cB +71yW5BbhS26IBkqy5o+u/KUdJGEQZ3kFcNn+7IFcTlhUMfmbz17GiVP60g2e9gW D91lvWyTH7CA+1pKoHAMtjK+U6KC9uclnWRObYPHHJjDyLdJBoRDD6r8SYn4fdiD dFRoV9tYhTRJYu170py6DybQ98qHnOe4uOO9Occdv34wXNcylPU4MOaUrFaFIqEF QyUwaQCzkUreLewUb65O/2FkyHZCsYIC+P7rDhTkNOHywb14urwZ7AfQ964dxLj4 Cnnc6LgI4+MFJeB8oxwyCWDC0Jx+DjuF4rhg981aRnqCZYa5HryDAQLD2BkYCZs= =nzdf -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Hi Felix, On Mon, Jul 8, 2013 at 4:09 AM, Felix Miata <mrmazda@earthlink.net> wrote:
Anyone know a good source of examples for dweebs who can't remember from one scripting writing session to the next anything new learned to get a task done, and requires examples rather than reading man pages to understand anything unfamiliar?
I have a script containing among other things the following:
grep 'using VT' /var/log/Xorg.0.log head -n7 /var/log/Xorg.0.log grep Output /var/log/Xorg.0.log | egrep -v 'disconnected|no monitor'
This works fine as long as it's run on a default X session, but not otherwise. I need to substitute for each "0" in the above strings the value of the actual display in use, which happens to be the last of the two visible characters of $DISPLAY. I tried to figure out if I could somehow apply the cut command to $DISPLAY, but got nowhere via its man page. Is what I want to do a for loop task? Can anyone here help with this seemingly simple goal?
Try this one: echo $DISPLAY | cut -d: -f2 Regards, -- Mark Goldstein -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 07/08/2013 05:49 AM, Mark Goldstein wrote:
echo $DISPLAY | cut -d: -f2
another way: let bash remove everything before the ":" (including the colon): $ echo "${DISPLAY#*:}" BTW: Please note that the DISPLAY variable can consist of another part, e.g. "localhost:0.0" has the same meaning as ":0". Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Thanks to all who replied, both on and off list. Here's the whole current script: # run this in X terminal echo "$ grep 'using VT' /var/log/Xorg.#.log" grep 'using VT' /var/log/Xorg.`echo $DISPLAY|cut -d: -f2`.log echo $ grep PRETTY /etc/os-release grep PRETTY /etc/os-release echo $ head -n7 /var/log/Xorg.#.log head -n7 /var/log/Xorg.`echo $DISPLAY|cut -c2`.log echo "$ grep Output /var/log/Xorg.#.log | egrep -v 'disconnected|no monitor'" grep Output /var/log/Xorg.`echo $DISPLAY|cut -c2`.log | egrep -v 'disconnected|no monitor' echo $ 'grep -v ^\# /etc/X11/xorg.conf.d/50-monitor.conf | grep DisplaySize' grep -v ^\# /etc/X11/xorg.conf.d/50-monitor.conf | grep DisplaySize echo $ 'grep -v ^\# /etc/X11/xorg.conf | grep DisplaySize' grep -v ^\# /etc/X11/xorg.conf | grep DisplaySize echo $ 'grep -v ^\# /etc/X11/xorg.conf.d/50-monitor.conf | grep PreferredMode' grep -v ^\# /etc/X11/xorg.conf.d/50-monitor.conf | grep PreferredMode echo $ 'grep -v ^\# /etc/X11/xorg.conf | grep PreferredMode' grep -v ^\# /etc/X11/xorg.conf | grep PreferredMode echo "$ xrdb -query | grep dpi" xrdb -query | grep dpi echo "$ xdpyinfo | egrep 'dime|ution'" xdpyinfo | egrep 'dime|ution' echo "$ xrandr | head -n5" xrandr | head -n5 After seeing the replies and looking at the cut man page again, I tried and found cut -c2 to work, even though I didn't and don't understand the description of that usage. Based on the description, I expected -c0123 or -c0,1,2,3 to work. Maybe that's why those who suggested -d: -f2 suggested what they did. I also tried both -f1 and -f2 with and without -d:. I don't understand why -d: -f2 works. The -d: part I sort of get, but not why 2 and not 1 after -f. I have several uses for this script. One is that I run it in Konsole and include it in a fullscreen screenshot to document how the desktop got configured to look the way it looks. The others are about getting info for Xorg and DE troubleshooting, bug definition/isolation and problem recreation. What I'd like to do to refine if further WRT getting the distro release name, current executable lines 3 & 4 of the script. Older Linux distros had no such file os-release. Those I've ever used do have various *-release files, but I wouldn't want to clutter the script's output with output from the several different ones from a single distro as is often the case. A more doable improvement would likely be a tail on a longer Xorg log head when the head starts with several pre-release notice lines. For that I'd want to incorporate John H's suggestion to reuse the output from a single instance of echo $DISPLAY|cut.... -- "The wise are known for their understanding, and pleasant words are persuasive." Proverbs 16:21 (New Living Translation) Team OS/2 ** Reg. Linux User #211409 ** a11y rocks! Felix Miata *** http://fm.no-ip.com/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Felix Miata said the following on 07/08/2013 08:14 AM:
I don't understand why -d: -f2 works. The -d: part I sort of get, but not why 2 and not 1 after -f.
Because you want the second field. it goes <field> <delimiter> <field> [ <delimiter> <field> .... } so you have hostname : 0.0 field delimiter field field #1 is the hostname field #2 is the screen number The real question is "Why is this not zero indexed?" -- Most good crime on this planet involves insiders. -- Bruce Schneier -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2013-07-08 08:29 (GMT-0400) Anton Aylward composed:
Felix Miata wrote:
I don't understand why -d: -f2 works. The -d: part I sort of get, but not why 2 and not 1 after -f.
Because you want the second field.
Of course that's what a 2 would mean, but....
it goes <field> <delimiter> <field> [ <delimiter> <field> .... }
so you have
hostname : 0.0 field delimiter field
field #1 is the hostname field #2 is the screen number
The real question is "Why is this not zero indexed?"
Why should anything humans use be zero indexed? The first thing we count is the first thing we count, 1, not zero. Zero means zilch, nothing, nada, less than one thing. The real question is what does hostname have to do with anything (aka how does :0 get to be a second field): # echo $DISPLAY :0 ??? -- "The wise are known for their understanding, and pleasant words are persuasive." Proverbs 16:21 (New Living Translation) Team OS/2 ** Reg. Linux User #211409 ** a11y rocks! Felix Miata *** http://fm.no-ip.com/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Felix Miata wrote:
On 2013-07-08 08:29 (GMT-0400) Anton Aylward composed:
Felix Miata wrote:
I don't understand why -d: -f2 works. The -d: part I sort of get, but not why 2 and not 1 after -f.
Because you want the second field.
Of course that's what a 2 would mean, but....
it goes <field> <delimiter> <field> [ <delimiter> <field> .... }
so you have
hostname : 0.0 field delimiter field
field #1 is the hostname field #2 is the screen number
The real question is "Why is this not zero indexed?"
Why should anything humans use be zero indexed? The first thing we count is the first thing we count, 1, not zero. Zero means zilch, nothing, nada, less than one thing.
The real question is what does hostname have to do with anything (aka how does :0 get to be a second field):
# echo $DISPLAY :0
When the field delimiter is ':', the first field (hostname) is empty, the second is '0'. -- Per Jessen, Zürich (25.8°C) http://www.dns24.ch/ - free DNS hosting, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Felix Miata said the following on 07/08/2013 10:29 AM:
The real question is what does hostname have to do with anything (aka how does :0 get to be a second field):
# echo $DISPLAY :0
There is an implicit <delimiter> in the beginning and the end of line (just in case you are using awk and the record delimiter is over-ridden and set to be a blank line -- aka 'stanza mode') The second field is not ":0", it is "0" The ":" is a delimiter. -- Don't join the book burners. Don't think you're going to conceal faults by concealing evidence that they ever existed. Don't be afraid to go in your library and read every book... Dwight D. Eisenhower -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2013-07-08 13:30 (GMT-0400) Anton Aylward composed:
Felix Miata said the following on 07/08/2013 10:29 AM:
The real question is what does hostname have to do with anything (aka how does :0 get to be a second field):
# echo $DISPLAY :0
There is an implicit <delimiter> in the beginning and the end of line (just in case you are using awk and the record delimiter is over-ridden and set to be a blank line -- aka 'stanza mode')
The second field is not ":0", it is "0" The ":" is a delimiter.
While all this may well enough explain why -f2, I don't see any response to my hostname question precipitated by your prior response. -- "The wise are known for their understanding, and pleasant words are persuasive." Proverbs 16:21 (New Living Translation) Team OS/2 ** Reg. Linux User #211409 ** a11y rocks! Felix Miata *** http://fm.no-ip.com/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
* Felix Miata <mrmazda@earthlink.net> [07-08-13 15:08]:
On 2013-07-08 13:30 (GMT-0400) Anton Aylward composed:
Felix Miata said the following on 07/08/2013 10:29 AM:
The real question is what does hostname have to do with anything (aka how does :0 get to be a second field):
# echo $DISPLAY :0
There is an implicit <delimiter> in the beginning and the end of line (just in case you are using awk and the record delimiter is over-ridden and set to be a blank line -- aka 'stanza mode')
The second field is not ":0", it is "0" The ":" is a delimiter.
While all this may well enough explain why -f2, I don't see any response to my hostname question precipitated by your prior response.
from google :^) :: http://unix.stackexchange.com/questions/16815/what-does-display-0-0-actually... -- (paka)Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 http://en.opensuse.org openSUSE Community Member Registered Linux User #207535 @ http://linuxcounter.net -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2013-07-08 15:21 (GMT-0400) Patrick Shanahan composed:
http://unix.stackexchange.com/questions/16815/what-does-display-0-0-actually...
Good to know. :-) I've updated my script to include Linda's and Brian's alternative to using cut: echo ${DISPLAY##*:} Whether I'll be able to look at the script a year from now and have any clue how it does what it does is anyone's guess. :-p -- "The wise are known for their understanding, and pleasant words are persuasive." Proverbs 16:21 (New Living Translation) Team OS/2 ** Reg. Linux User #211409 ** a11y rocks! Felix Miata *** http://fm.no-ip.com/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
* Felix Miata <mrmazda@earthlink.net> [07-09-13 02:25]:
On 2013-07-08 15:21 (GMT-0400) Patrick Shanahan composed:
http://unix.stackexchange.com/questions/16815/what-does-display-0-0-actually...
Good to know. :-)
I've updated my script to include Linda's and Brian's alternative to using cut:
echo ${DISPLAY##*:}
Whether I'll be able to look at the script a year from now and have any clue how it does what it does is anyone's guess. :-p
That is probably a "Good Reason"(!tm) to comment your code :^). -- (paka)Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 http://en.opensuse.org openSUSE Community Member Registered Linux User #207535 @ http://linuxcounter.net -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Felix Miata wrote:
While all this may well enough explain why -f2, I don't see any response to my hostname question precipitated by your prior response.
If you log in remotely, PAM will set the host you log in from on first contact to the system in PAM_RHOST during authentication. This is usually used in /etc/security/pam_env.conf, to set the env once per-contact session with the system -- usually 'REMOTEHOST' to where you came from and DISPLAY would get ${$REMOTEHOST:X-server.screen}. Recently, in 11.3, I believe, SuSE broke this by redefining session to anytime you change seats. So they run PAM_ENV on each new seat change -- zeroing out your REMOTEHOST and DISPLAY -- making them worthless. I tried to have it fixed, but the maintainer on pam knows he wants pam_env to set the env for each seat-session -- thus making the documented usage of the file worthless in the default suse configuration. If you log in with 'ssh', and it is tunnelling your 'X' session, it will setup a socket thatw ill set DISPLAY to localhost:tunnelid. However, if you are on a local network you DON'T want that. It slows down X and raises latency by a noticeable amount even on a 1Gb network. The difference on faster networks is proportionately worse, since ssh encryption will knock off a sizeable percentage. But if you are going over the internet/ insecure lines... you run risks of password sniffing if you aren't careful (could use certs to login)... I use the presence or absence of REMOTEHOST to change my prompt -- If I am logged in remotely, I display the host I am logged into, else not. BTW, if you want the numeric field (which could be 0.0 or 1.0, not just 0 or 1), you can do it in bash-only without cut: ${DISPLAY#*:} "#" pounds down the beginning of a the contents of a var, while % is a modulus type operator in many languages, and I think of it cutting off the tail of the contents of a var... So ${VARNAME#<expression to match the front you want to pound off -- in this case a hostname:, so I used *:. If I wanted to truncate the tail and just get the hostname part, I'd use ${VARNAME%:<expression to match anything after ':'> or a '*' for DISPLAY... Note ## and %% will use the longest match that will fit your specification, while # and % will use the shortest: if A=/usr/local/bin/foobar, then ${A%/*} = /usr/local/bin && ${A%%/*} = /usr ${A#*/} = usr/local/bin/foobar (cuz */ matches the empty string and 1st slash) while ${##*/} = foobar (take off everything including the last '/'). BASH also has substitution: a="one two three four" echo ${a/ /,} = "one,two three four" && echo ${a// /,}= "one,two,three,four" (the double // does all of them). cut will work, but if you can remember the #(pound)off the front, and %truncate or chop off the back that solves alot of tiddly problems. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Felix Miata said the following on 07/08/2013 10:29 AM:
Why should anything humans use be zero indexed? The first thing we count is the first thing we count, 1, not zero. Zero means zilch, nothing, nada, less than one thing.
Right. Zero offset into the ... whatever. The beginning. What you get to before you start counting up. You're not an American are you? You call the ground floor of a building the ground floor, not the first floor. -- "Quality is not a sprint; it is a long-distance event." Daniel Hunt. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2013-07-08 13:33 (GMT-0400) Anton Aylward composed:
You're not an American are you?
100% second generation of 100% western European ancestry. I read and speak only English.
You call the ground floor of a building the ground floor, not the first floor.
Around here, relatively few buildings have more than one floor level. The water table here is so high that basements or other floors below surrounding elevation are extraordinarily rare. If I had a building with 13 floors, none of which below a uniform surrounding elevation, the bottom of the stack would be #1, regardless of its actual elevation, and the top floor would be #13. Why any elevators for buildings with any floor(s) below surrounding uniform elevation have both G and 1 buttons escapes me. I have seen elevators in buildings in other areas with below ground floor levels with buttons labeled e.g. B1, L2, or S3, etc. I have not been around enough buildings with non-uniform surrounding elevation to know what floor naming is common or makes good sense. I would still call the lowest floor #1 if little or none of it was below lowest surrounding elevation. Does any of this really have anything to do with $SUBJECT? -- "The wise are known for their understanding, and pleasant words are persuasive." Proverbs 16:21 (New Living Translation) Team OS/2 ** Reg. Linux User #211409 ** a11y rocks! Felix Miata *** http://fm.no-ip.com/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 07/08/2013 02:14 PM, Felix Miata wrote:
After seeing the replies and looking at the cut man page again [...]
Just a reminder: cut is from GNU coreutils, and as a GNU package it comes with proper documentation in Texinfo format, and the man page is just a copy from "cut --help". Therefore: $ info coreutils or move directly to cut: $ info coreutils 'cut invocation' Some folks like "pinfo" more than "info", though. Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Tue, 09 Jul 2013 22:39:20 +0200 Bernhard Voelker <mail@bernhard-voelker.de> wrote:
Some folks like "pinfo" more than "info", though.
Some use Konqueror and as URL: info:coreutils or ##coreutils or in case of man pages: man:bash or #bash # and ## are shortcuts for 'man:' and 'info:', that will list all man or info pages when given without wanted page. Nice about Konqueror as reader is that related pages in section "SEE ALSO" are links. This is a single feature which makes worth using it. Not nice is that it will not attempt to find 'man:Xorg' if one types 'man:xorg', but nice is that: man:/xorg will list all pages starting with Xorg or xorg, or whatever you typed to that moment, so you will see list: man:/Xorg man:/xorg.conf man:/xorg.conf.d and 'man:xorg' if you already tried to access that. -- Regards, Rajko. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sunday, 2013-07-07 at 21:09 -0400, Felix Miata wrote:
Anyone know a good source of examples for dweebs who can't remember from one scripting writing session to the next anything new learned to get a task done, and requires examples rather than reading man pages to understand anything unfamiliar?
Heh, I have the same problem. I have a text file with a collection of small samples, But always I need something else that is not collected there, and I have to grep in scripts all over the place to find it. - -- Cheers, Carlos E. R. (from 12.3 x86_64 "Dartmouth" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iEYEARECAAYFAlHa8sAACgkQtTMYHG2NR9XhDwCdEndRUFBes8T5pzU/jSfYIGli p3MAoJMxPlKP0FNkZ6X3TBmAnWpBi+lq =sH28 -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Carlos E. R. wrote:
-----BEGIN PGP SIGNED MESSAGE-----
On Sunday, 2013-07-07 at 21:09 -0400, Felix Miata wrote:
Anyone know a good source of examples for dweebs who can't remember from one scripting writing session to the next anything new learned to get a task done, and requires examples rather than reading man pages to understand anything unfamiliar?
Heh, I have the same problem.
I have a text file with a collection of small samples, But always I need something else that is not collected there, and I have to grep in scripts all over the place to find it.
I finally started collecting scripts (bash & perl) into a lib dir. I had to write my own include to allow hierarchical includes like: include Util/Needroot I have functions in my .bashrc and .bash_env to make aliases available and a list of my GROUPS(by name) I put a standard prologue at the beginning of my scripts to make sure paths and such are set correctly for my lib usage. include errnos -- (defines all the EAGAIN type vars on your system from your errno.h). Have scripts to setup my network interfaces now, rename them to constant names, (by their etherID), assign network priorities using cgroups... et al... -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 7/7/2013 9:09 PM, Felix Miata wrote:
Anyone know a good source of examples for dweebs who can't remember from one scripting writing session to the next anything new learned to get a task done, and requires examples rather than reading man pages to understand anything unfamiliar?
One of my favorites was always "shelldorado" if only because of the great name :) www.shelldorado.com
I have a script containing among other things the following:
grep 'using VT' /var/log/Xorg.0.log head -n7 /var/log/Xorg.0.log grep Output /var/log/Xorg.0.log | egrep -v 'disconnected|no monitor'
This works fine as long as it's run on a default X session, but not otherwise. I need to substitute for each "0" in the above strings the value of the actual display in use, which happens to be the last of the two visible characters of $DISPLAY. I tried to figure out if I could somehow apply the cut command to $DISPLAY, but got nowhere via its man page. Is what I want to do a for loop task? Can anyone here help with this seemingly simple goal?
In bash, (this syntax only works in bash or real at&t ksh93 and maybe zsh): echo ${DISPLAY##*:} What that did was delete everything up to and including, the last ":" in $DISPLAY, and show you whatever was left. The contents of DISPLAY are not changed. This is just an expansion filter. It's like reading something through a filter. The original thing you read isn't changed by the filter, you just see something different than the source. A single # would have deleted up to and including the first :, which is often the same thing if there is only one, but the more correct thing is to grab everything after the last :, even if there may just happen to be only one of them usually. The *: is the pattern of what to delete In "man bash" search (hit the "/" key) for "parameter#word". Of course, see the whole Parameter Expansion section while you're there. Lot's of handy goodies. Like you often don't really need the dirname or basename or cut or tr or even sed commands. -- bkw -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (11)
-
Anton Aylward
-
Bernhard Voelker
-
Brian K. White
-
Carlos E. R.
-
Felix Miata
-
Linda Walsh
-
Mark Goldstein
-
Patrick Shanahan
-
Per Jessen
-
Rajko
-
Thomas Taylor