Questions tagged [conditional-statements]

100 questions
22
votes
1 answer

Comparing two strings in zsh

I've been looking everywhere for what should be a simple example. First time trying to script something for zsh now that MacOS has switched over to it as default - how do I compare two strings in an if statement? I tried the following but continue…
18
votes
6 answers

Using a wildcard in a condition to match the beginning of a string

Trying to have a variable meet a string of text that varies by length. The part of the string that matters is the first couple of characters. var1=hello if [ $var1 == hello ]; then echo success fi Or var1=hello if [ $var1 == h*o ];…
EAG08
  • 181
8
votes
2 answers

How does bash test 'false'?

$ false $ echo $? 1 $ if [[ false ]]; then echo 'do it'; fi do it $ test false && echo 'do it' do it $ COND=false $ echo $COND false $ if [[ $COND -ne 0 ]]; then echo 'do it'; fi $ if [[ $COND -ne true ]]; then echo 'do it'; fi This is nonsense…
4
votes
1 answer

Batch File IF Statement Time Taken

I am trying to write a batch file that takes the time taken of a command and converts it into hours, minutes and seconds. Here's what I've got: @echo off set /a sec=0 set /a min=0 set /a hrs=0 for /f %%G in ('ping localhost -n 100 >nul') do ( …
4
votes
1 answer

Bash script that execute command only if port is free

Hi I have a bash script that needs a conditional execution of a few lines of code based on whether port 80 is already in use: sudo git fetch origin; sudo git checkout master; sudo git pull; --- if port 80 open echo Starting Meteor; export…
4
votes
2 answers

Multiple IF statements and concatenation in Excel

So far I've managed to concatenate cells I1 and J1 with the words "From" and "To" and put them on separate lines using: =CONCATENATE("From: ",I1," ","To: ",J1) I've also managed to populate column L (only if there is data in column H) using this:…
3
votes
1 answer

SUMPRODUCT and IF conditional (LibreOffice)

I would like to multiply two cells in a same row, if a condition of a third adjacent cell is met; then sum the result to the next product in the next row (if condition is met), and so on. | A | B | C | ---|---|---|---| 1 | | | | 2 | | …
3
votes
1 answer

Using conditional filters in FFmpeg

It blew my mind when I recently came across something new about FFmpeg despite having used it for years - the fact that it comes out of the box with advanced conditionals like if statements and lt/gt for filters. To me this has to be its most…
Hashim Aziz
  • 13,835
3
votes
2 answers

Write a formula for "If Cell 1 contains a keyword, Then Cell 2 changes background color"

I have a list of pages in column A. I want certain cells in column B to be highlighted if the cell B1 contains the word Hotel. See below example where cells B2, B5, B8, and B10 have a background color red because B1 has the text Hotel. I tried using…
AndrewH
  • 213
3
votes
1 answer

windows 7 search: multiple condition "find folders of this size that does not contain this and that"

Windows 7 search allows to find specific files type and exclude some using some operators (such as AND OR NOT) but how to add multiple search condition on these following example? Ex 1: this query doesn't work: type:folder size:tiny EX 2: searching…
JinSnow
  • 912
2
votes
1 answer

IF and then condtional format

In Column C, I Want to rename the Column A Name in order of Date Of Birth, but only if a duplicate is found. Otherwise, the name in Column C should be the same as Column A. For example, there are two Ajays, so the elder is Ajay 1, the younger is…
2
votes
1 answer

Excel 2010 - more than 1 calculation within an IF() statement

I have a situation where I need to calculate shipping values based on the length of the supply chain. Easy, however I need to have instances where an increased amount is required based on specific date criteria. My example is as follows: Shipvalue…
2
votes
4 answers

How to rewrite a wall of if-elif statements

For cigs.sh - the complete script can be found here - I wrote the following ugly (but perfectly working) logic to print and format the script's output, partly just to figure out all the edge cases but also because I didn't see any other…
2
votes
0 answers

Ignoring /substituting missing certificate files in apache 2.4 config

Are there any directives or constructs I can use in Apache 2.4 to prevent Apache from failing to load at all if a certificate file is missing for an https Virtualhost is missing. (I am dealing with a process that - on a remote system - creates a…
2
votes
1 answer

Sending specific email based on cell values in Excel 2016?

Is there a more efficient way to send email reminders to a user based on a cell value that changes frequently? Here's the code of what I'm working on so that you guys could understand the context of the question. 'This is the main function Sub…
1
2 3 4 5 6 7