How do you tell if a string contains another string in POSIX sh? I want to write a Unix shell script that will do various logic if there is a string inside of another string. For example, if I am in a certain folder, branch off. Could someone please tell me how to accomplish this? If possible I would like to make this not shell specific (i.e. not bash only) but if there's no other way I can make do with that.  #!/usr/bin/env sh  if [ "$PWD" contains "String1" ] then     echo "String1 present" elif [ "$PWD" contains "String2" ] then     echo "String2 present" else     echo "Else" fi
How to check if a string contains a substring in Bash I have a string in Bash: string=&quot;My string&quot;  How can I test if it contains another string? if [ $string ?? 'foo' ]; then   echo &quot;It's there!&quot; fi  Where ?? is my unknown operator. Do I use echo and grep? if echo &quot;$string&quot; | grep 'foo'; then   echo &quot;It's there!&quot; fi  That looks a bit clumsy.
Javascript add leading zeroes to date How do I access $HOME/storage Termux directory on Android Pie with a GUI File Explorer?  In Termux I print the working directory with pwd and it shows $HOME/storage as:  /data/data/com.termux/files/home   My internal storage looks like this:  . ├── Alarms ├── Android |   ├──data |   |  ├── ... |   |  ├── com.termux |   |  |   └── files |   |  |       └── 0 items |   |  └── ... |   └── ... ├── DCIM ├── Download └── ...   My external storage looks like this:  . ├── Android |   ├──data |   |  ├── ... |   |  ├── com.termux |   |  |   └── files |   |  |       └── 0 items |   |  └── ... |   └── ... └── LOST.DIR   Neither my internal storage, nor my sd card, contain a /data/ directory at the root level. Where is this /data/ directory? For that matter, where is the root /storage/ directory? Where is the root /emulated/ directory? Where are any of these directories and why cant I access any of them? for (i=0 ; i&lt;=10; i++) {     ..     .. }  i=0; while(i&lt;=10) {     ..     ..     i++; }   In for and while loop, which one is better, performance wise? Can noindex tags on several pages affect the overall SEO or ranking on Google? Some SEO Gurus assured me that noindex attributes are good to devalue the unimportant pages.   When I asked in the moz Q and A, they're quite sure that having noindex on the bulk of the articles on the website can harm overall SEO ranking.   Which is true? QGIS apply style to shapefile Why would you use an assignment in a condition? In many languages assignments are legal in conditions. I never understood the reason behind this. Why would you write:  if (var1 = var2) {   ... }   instead of:  var1 = var2; if (var1) {   ... } How can I attack an enemy's weapon? I want to hit enemy's axe to break it. How this is properly played in D&amp;D 5e? And what about shield or armor? Can I attack these items to break it? I seem to have run into a bit of a challenge on one of our Android/Samsung devices...   On the device, regardless of what's open, when the battery reaches 25% on discharge, the below screen pops up and covers the entire screen, with MUCH difficulty to get rid of. I've tried to trace it to a certain app, but was unsuccessful in doing so.     Can someone perhaps help with some advice on this, on how to get rid of it? I recall being somewhat impressed by a novel I read a few years back – this book may be less than five years old – which featured a college-aged man.  He had a laptop which transformed into a troll goblin that served as his familiar.  In the story's universe, mages had switched to the Internet for most of their magic &amp; communication.  The main character was essentially a magical hacker, and spent much of the book fighting against his evil aunt (I think, I know it was a female relative) with the help of his cousin.  Older forms of magic were also featured, including using special paintings as magical portals, and spells being whistled by wizards.  It features a scene at a gas station where the laptop is disabled by a virus, and the main character whistles a spell to reanimate dinosaurs from the gasoline.  Is this ringing any bells? What is covered by CDIC savings deposit insurance? In the unlikely event that a financial institution fails in Canada, what is covered by the Canadian Deposit Insurance Corporation?  What is the limit of coverage? I deleted an answer which had no upvotes or downvotes, but after some time I saw that my reputation was -2 and the reason is linked to my search engine.    I want to know why this happened and what "linked to my serach engine" means? Shouldn't the association bonus acquired via serial upvoting be reversed? When a user's rep gets bloated because of serial upvoting, and as result the user is given the association bonus, shouldn't that association bonus also be reversed in case of serial upvoting reversal? Expression for a choice which isn't really one Maven check for updated dependencies in repository How can I set a dark theme in TeXstudio? After perusing , I'm considering switching from TeXmaker (in which I use the preset "dark theme") to its fork, TeXstudio.  What I mean by "dark theme" is a dark background with suitable text colours, which, in my experience, is easier on the eyes than a bright background is. Here is an example:    TeXstudio doesn't seem to offer any preset dark theme, though, which means I have to customise all the colours/syntax-highlighting settings from scratch to get a dark theme even remotely usable. This can prove very time-consuming.   I'm aware this might sound a bit cheeky but,   if you are a long-time TeXstudio user, and you have fine-tuned the editor colours to get a visually pleasant dark theme,   please consider posting the relevant lines from your settings (.txsprofile or .tmxprofile) file as an answer below.  TeXstudio users who would like to use a dark theme could then build on your settings to fine-tune their own. How to interpret a QQ plot I am working with a small dataset (21 observations) and have the following normal QQ plot in R:     Seeing that the plot does not support normality, what could I infer about the underlying distribution? It seems to me that a distribution more skewed to the right would be a better fit, is that right? Also, what other conclusions can we draw from the data? How to add a confirm dialog to a command button? I'd think this would work just fine, but it seems to prevent the action function from firing regardless of the confirm response  &lt;apex:commandButton value="Remove All" action="{!removeAll}" rerender="form"      status="LoadingStatus" onclick="return confirm('Are you sure?');"/&gt; I need to add a coloured line before my caption; this is what I used:  \usepackage[labelfont=bf]{caption}  \DeclareCaptionFormat{myformat}{\hrulefill #1  #2 #3} \captionsetup[figure]{format=myformat}   but the figure turns out to be line this:    and not a horinzontal line which what I want  2) I want the line to be coloured RGB [152 204 204] with thickness about the same as \top rule. Can anyone show me how to do this? Is there a hack to force Twitter not to convert words like ASP.NET to links? Currently, Twitter converts anything that has dot inside it into a link, e.g. ASP.NET becomes , Any.DO becomes  etc. I currently make a space if I want the word to stay the way it should, e.g. "ASP. NET" though it is not right.  Is there a hack around this Twitter bug? Like if there would be some unicode character that looked like a dot and could be inserted there or something like that. Generators and relations for $\text{PSL}(2, \mathbb{F}_q)$ Is there a nice presentation for the group $\text{PSL}(2,\mathbb{F}_q)$, for every prime $q$?  (I don't have any particular definition in mind for "nice", other than, say, a small number of generators and relations.)