Skip to content
Advertisement

Tag: if-statement

How can this bash script be made shorter and better? Is there a way to combine multiple curl statements and if statements in bash?

The main script is scheduled and runs everyday and prints the success message everytime. If the status code is anything other than 200, $Status_code_1 or $Status_code_2, whichever is down prints the error code. The code is working fine but I want to know how can it be made shorter. Can the curl command from first 2 lines be combined because

Using Awk to print the unavailable record only once

I am writing an awk script which looks like this inside: This is my file. This tries to print the else if method once, but instead, it prints for all of the lines that do not include the searched value. If I entered 20, my output looks like this: I have to use the awk command to print else if

how to use IF to test if a value meets a certain mask

I have a variable and I need to test if it contain a formated value like this ……..-….-….-….-………… the variable can contem any value in any format, and I need to test if the value is like 1572C097-4452-4495-8369-C7606F2C867E I tried using sed to retrieve the value from another variable But now, I dont have a clue how can I use

implementing Excel if-like function with AWK

I have a question about Excel-if-function implementation with AWK. I have a csv file having eight columns like below: Each field can take only integer values from 1 to 6. I would like to give one point if the first column is 1. In other cases, the score would be zero. In this MWE case, the point for all three

How logical operators works

I tried below but it doesn’t work. Throwing some errors. Exp1 or expr2 should evaluate first & at result should be evaluated with expr3 ( &&) i tried as per suggestion, it throws error as Fyi- that date is val1 value. Answer You might see different results based on the shell or version, eg: sh vs bash vs ash. One

How to build a conditional while statement in Bash?

Hello Stackoverflow community, In order to make my code as less ‘copy-paste-ey’ as possible, I’m trying to come up with a smarter method to make it more compact. Is there any way to create a ‘conditional while’-statement (if that’s even a thing) in your script without having to repeat everything over again? Basically, I have the same core function, but

Bash Script is not working [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 4 years ago. Improve this question When i am writing the script like this the script is working. but

Advertisement