Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #172833
| From | The Wanderer <wanderer@fastmail.fm> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: Substring search in dash [ _NOT_ bash ] shell |
| Date | 2016-09-27 06:20 +0200 |
| Message-ID | <slS25-4Nx-1@gated-at.bofh.it> (permalink) |
| References | <slGki-5BO-7@gated-at.bofh.it> <slGki-5BO-5@gated-at.bofh.it> <slRIJ-4r1-9@gated-at.bofh.it> |
| Organization | This space intentionally left blank. |
[Multipart message — attachments visible in raw view] - view raw
On 2016-09-26 at 23:49, Richard Owlett wrote:
> On 9/26/2016 10:42 AM, Greg Wooledge wrote:
>
>> On Mon, Sep 26, 2016 at 10:39:59AM -0500, Richard Owlett wrote:
>>
>>> # string if [ "`hostname`" = bob ]; then echo bob.cfg; fi
>>>
>>> I need for the case when evaluates to marybobsam .
>>> I can find examples in bash shell, but I need dash.
>>
>> Are you asking how to check for the substring "bob" in your input,
>> in POSIX sh? Use case, and a glob:
>>
>> case $input in
>> *bob*) echo "Bob found." ;;
>> esac
>>
>> case $(hostname) in
>> *bob*) echo "I must be a Bob." ;;
>> esac
>
> Thank you. I was expecting an if...fi construct.
Some such thing could be used when checking for an exact string, but for
substring matching, the example given is better.
> Is dash documented anywhere?
> All I've found are pages saying that some "bashisms" do not work
> in dash :<
The dash manual page ('man dash') seems fairly comprehensive, on brief
observation. It doesn't seem as lengthy or as detailed as the bash man
page (which I _have_ actually read full-length, believe it or not), but
it does seem to cover most things.
--
The Wanderer
The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. -- George Bernard Shaw
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Substring search in dash [ _NOT_ bash ] shell Greg Wooledge <wooledg@eeg.ccf.org> - 2016-09-26 17:50 +0200
Re: Substring search in dash [ _NOT_ bash ] shell Richard Owlett <rowlett@cloud85.net> - 2016-09-27 06:00 +0200
Re: Substring search in dash [ _NOT_ bash ] shell The Wanderer <wanderer@fastmail.fm> - 2016-09-27 06:20 +0200
Re: Substring search in dash [ _NOT_ bash ] shell David <bouncingcats@gmail.com> - 2016-09-27 10:00 +0200
csiph-web