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
Tag: shell
Single quoted full path files in a text file can’t do for loop processing mv: cannot stat … No such file or directory
I have a test file which contains a space-separated files that I want to move/delete. Example line: I want to move the files away to another directory in a for loop: But it gives me an error. Why? 2nd problem after this how could I move actually this file to the new place with included the original directory somehow in
why is the error occuring when i am running the script.how can i fix it?
Here is the script was written which is based on while loop in shell scripting in Linux. I used a variable and wanted to increase the value of it till the value is less than 10. What problems could have occurred in the script? To find out I ran the script and the error is coming. Answer In line 6,
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
convert text file to html ouput so that data can be printed in table format
I have a text file which has 3 values separated by : and so on. I want to print the output to a html type tabular format file, which has 3 headings, date, output and system and corresponding data in 3 columns. I tried below code, but it is not putting data to table format. Answer If you can, please
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