bash

Removing Duplicate Domain URLs From the Text File Using Bash

Removing Duplicate Domain URLs From the Text File Using Bash Question: Text file https://www.google.com/1/ https://www.google.com/2/ https://www.google.com https://www.bing.com https://www.bing.com/2/ https://www.bing.com/3/ Expected Output: https://www.google.com/1/ https://www.bing.com What I Tried awk -F’/’ ‘!a[$3]++’ $file; Output https://www.google.com/1/ https://www.google.com https://www.bing.com https://www.bing.com/2/ I already tried various codes and none of them work as expected. I just want to pick only one unique …

Total answers: 2

Calling python script from bash script and getting it's return value

Calling python script from bash script and getting it's return value Question: I’ve bash script doing some tasks but I need to manipulate on string obtained from configuration (for simplification in this test it’s hardcoded). This manipulation can be done easily in python but is not simple in bash, so I’ve written a script in …

Total answers: 2

Passing arguments through Docker to argparse not working

Passing arguments through Docker to argparse not working Question: The setup I have a dockercontainer with the following Dockerfile: FROM python:3.10 WORKDIR /usr/src/app ENV ARGS="" COPY requirements.txt ./ COPY main.py ./ COPY … COPY … COPY … RUN apt update RUN apt install ffmpeg -y RUN apt install wkhtmltopdf -y RUN pip install –no-cache-dir -r …

Total answers: 1

sed and rev shell command into Python script

sed and rev shell command into Python script Question: There is a shell command, I am trying to convert the logic into python. But I don’t know what to do, I need some help with that. shell command is this : cd ../../../tests/src/main/test ls find . -name ‘*.vrlp’ | while read FILENAME do TEST_CASE=`echo $FILENAME …

Total answers: 1

Shell find logic into Python script

Shell find logic into Python script Question: cd db/test/vs ls find . -name ‘*.vrlp’ | while read FILENAME do TEST_CASE=`echo $FILENAME | sed s/"./"//g | sed s/".vrlp"//g | rev | cut -f1 -d"/" | rev` CLASS=`echo $FILENAME | sed s/"./"//g | sed s/"/$TEST_CASE"//g | sed s/".vrlp"//g` done There are a lot of class files (FILENAME) …

Total answers: 1

sed shell command into Python script

sed shell command into Python script Question: There is a shell command, I am trying to convert the logic into python. But I don’t know what to do, I need some help with that. shell command is this : cd ../../../tests/src/main/java ls grep -R "@Test" -A 1 | grep void | while read LINE do …

Total answers: 1

Translate multi-command pipeline bash to python

Translate multi-command pipeline bash to python Question: This is what I have in my bash script: example=$(echo $var | cut -c 40- | sed "/[a-zA-Z0-9]$/!d"). I am trying to translate it to python. In Python, echo $var | cut -c 40- would give print(var[40]). And I know that [a-zA-Z0-9] means any character in the range …

Total answers: 1

Translating Bash to Python

Translating Bash function call to Python Question: I am trying to translate this from Bash to Python: password=$(func_name "${configFile}" "<password" "2") func_name and configFile have been defined earlier in the script. func_name is a function and configFile is a working directory leading to an XML file. But I don’t know what to do with func_name …

Total answers: 1