Why does curl not return a value in bash script?

My task is very simple – nevertheless I have been sitting already for hours and have no idea why it doesn’t work. In linux bash script I want to get the result of a webservice call with curl. I’m not interested in the content, only the status code: #!/bin/bash set -euo pipefail # put bash… Read More Why does curl not return a value in bash script?

How to get a list of merge commits to develop that are not merged to master … and vice versa

Our workflow is very manual at the moment. Jira for tickets, Bitbucket for repos. Many repos. Way too many repos. Using Sourcetree, showing the develop branch, parents only, compare against a spreadsheet we have maintained for years of all the different repos and so we can see (and make reports/charts) of what and when merges… Read More How to get a list of merge commits to develop that are not merged to master … and vice versa

how to count duplicates in a list of tuples and append it as a new value

output = [(‘studentA’,’ISDF’), (‘studentB’,’CSE’),(‘studentC’,’BIO’),(‘studentA’,’ISDF’), (‘studentB’,’CSE’),(‘studentC’,’BIO’),(‘studentA’,’ISDF’), (‘studentB’,’CSE’),(‘studentC’,’BIO’),(‘studentA’,’ISDF’), (‘studentB’,’CSE’),(‘studentC’,’BIO’),(‘studentA’,’ISDF’), (‘studentB’,’CSE’),(‘studentC’,’BIO’),(‘studentA’,’ISDF’), (‘studentB’,’CSE’),(‘studentC’,’BIO’)] so here there are total of 6 set of (‘studentA’,’ISDF’), (‘studentB’,’CSE’),(‘studentC’,’BIO’) in this above list so Im expecting an output like this ~ expected_output = [(‘studentA’,’ISDF’,6), (‘studentB’,’CSE’,6),(‘studentC’,’BIO’,6)] The format should be [(‘student’, ‘department’, total count)] >Solution : Try this: sorted([tuple(list(item)+[output.count(item)]) for item in set(output)])

Bad substitution in Bash

I have written this code in which m getting bad substitution error. Please help here. #!/bin/bash function detect_value(){ #some operation gives u a value echo "ABCD" } ABCD_COUNT=26 echo "${"$(detect_value)"_COUNT}" bash run.sh run.sh: line 12: ${"$(detect_value)"_COUNT}: bad substitution >Solution : The name of a parameter has to be static, not produced by another expression. To… Read More Bad substitution in Bash

bash script to alter array elements and write to new array

I would like a bash script to take the elements from array1 and output them differently in array2. array1 – array1=(s3://root/sub1/sub2/ 2022-10-22 2021-09-13 2020-08-15 s3://root/sub1/sub2/ 2022-09-22 2021-08-07 2020-02-03  s3://root/sub1/sub2/ 2022-08-22 2021-07-17 s3://root/sub1/sub2/ 2022-07-22) array2- array2=(s3://root/sub1/sub2/2022-10-22/ s3://root/sub1/sub2/2021-09-13/ s3://root/sub1/sub2/2020-08-15/ s3://root/sub1/sub2/2022-09-22/ s3://root/sub1/sub2/2021-08-07/ s3://root/sub1/sub2/2020-02-03/ s3://root/sub1/sub2/2022-08-22/ s3://root/sub1/sub2/2021-07-17/ s3://root/sub1/sub2/2022-07-22/) So I basically want to take the url from array1 and append each date… Read More bash script to alter array elements and write to new array

Convert .csv to Excel file using bash shell script

I’m trying to convert a .csv file to Excel using unix shell script. Tried the below script but it didn’t work. ./csv2xls -csv-file-name="file1.csv" -xls-file-name="file1.xls" -csv-delimiter="|" I tried using the below script to convert csv to unix format dos2unix file1.csv Not sure how to convert it to Excel format. Can anyone guide how to convert this… Read More Convert .csv to Excel file using bash shell script

How do I correctly use variables with sed?

I need to use a string variable in a sed command. My attempt is given in script.sh, it does not do what I want, I assume because my variable contains characters that I need sed to evaluate. I am working in linux bash. input.txt delicious.banana gross.apple script.sh adjectives="delicious\|gross\|bearable\|yummy" sed "s/\($adjectives\)\.//g" input.txt > output.txt output.txt desired… Read More How do I correctly use variables with sed?

How do I extract specific strings from multiple files and write them to .txt in bash?

I have a lot of files in the folder filesToCheck, some examples given below. I need the output result.txt as also shown below. I can use linux bash with any commands that do not require extra installations. The try-out below (with help from stackoverflow) has two problems when I execute it. It only looks for… Read More How do I extract specific strings from multiple files and write them to .txt in bash?

Recursively unzipping a folder with ZipFile/Python

I am trying to write a script which can unzip something like this: Great grandfather.zip Grandfather.zip Father.zip Child.txt What I have so far: from os import listdir import os from zipfile import ZipFile, is_zipfile #Current Directory mypath = ‘.’ def extractor(path): for file in listdir(path): if(is_zipfile(file)): print(file) with ZipFile(file,’r’) as zipObj: path = os.path.splitext(file)[0] zipObj.extractall(path)… Read More Recursively unzipping a folder with ZipFile/Python