Skip to content
Advertisement

Tag: shell

How to iterate over two arguments in the sh linux shell

I have two sets of arguments: a = “5 7 1” and b = “dogs cats horse” They should come in pairs: 5 matches dogs, 7 matches cats and 1 matches horse They also should do this in one line: The problem is that the $a and $b can have hundreds of arguments, so writing many lines like the above

How do run executable c++ through terminal in debug mode?

I have a c++ executable file named test .. To execute it in my terminal I run….. Although I want to run it in debug mode wherein it shows the exact command being used immediately after being executed If you are wondering what exactly I mean by debug mode.. Just like how we use -x for shell scripts This shows

Stop grep message from posting

I am working on a script that take 1 string argument and a file. I want it so that if a file is put in that doesn’t exist, then it will display the “filename cannot be read” message. That part does work however it also displays a “grep: grep.txt: No such file or directory” message. Is there any way to

How to filter a “diff” command to exclude certain entries?

I have to take some text my professor has given me, put it into two files, and I have to use the “diff” function to compare those two files. But, some lines in those files are missing an entry in the 6th (last) column. I need to filter the diff command to exclude those lines. I tried to use the

Why decrement of variable inside loop returns no success status code?

I can’t understand why inside loop with condition of equal to 0 decrementing of variable returns non-zero status code (not success) if variable was decreased to 0? If I use a different condition for the loop – for example – until [[ $RETR -eq 1 ]] it returns 0 status code after last decreasing, the same situation for while loop

Arithmetic in Shell script

After executing this Here $20 indicates the “S:” entry in each row (I am taking the unique count of all s values),I am getting result as so what I need is the sum of all occurrence of s values .i.e 93070+11666+230 so result be total=104966 Answer

Assigning colors to HTML table columns based on conditions

I am using a bash script to send an email in html table format. I have a command like below. Columns are: scenario: When counts are matching then count_validation column will have ‘Matching’ with green color background else red color background. Same way for amounts. What am I missing or doing wrong in my code? Using the below statement I

Advertisement