All Questions
4,253
questions
1
vote
0
answers
69
views
exit status of if statement in bash when condition is false
If I run help if in bash then it tells me that the exit status is "the status of the last command executed". Let's try it:
if false; then
echo we never get here
fi
echo $?
The last ...
0
votes
1
answer
53
views
How to evaluate 2 variables using bash arithematic in if statement with AND operator in bash shell [duplicate]
I have an alphanumeric string, say something like "XXXX24Y2" from which i have extracted only the numbers and assigned them to 2 variables, say num1 and num2, say num1=24 and num2=2
Now i ...
-2
votes
0
answers
35
views
How to use a large number of credentials with a bash script [closed]
I have a script that needs to store a large number of usernames and passwords. Basically what my script does is it fetches the customer usernames and passwords to execute an API link to check every ...
-1
votes
0
answers
22
views
When I try to change a variable in a file I stack with error [duplicate]
I have two bash files:
1:
#!/bin/bash
PATH="/home/jk/go/src/emdr/emd_server"
sed -i 's|^COMPOSE="[^"]*"|COMPOSE="'$PATH'/docker_compose.yml"|' "$PATH/up/...
1
vote
1
answer
74
views
How to manage non ASCII characters inside sh/bash scripts
My terminal.txt file in the sequel
shows the output of my tmpPdfFile.sh and tmpPdfFile1.sh scripts:
both scripts are unable to properly manage the file
"6._ANbertà_di_scelta.docx.pdf"
The ...
-1
votes
1
answer
48
views
Variable expansion in "Run" command in docker [duplicate]
Example 1:-
FROM ubuntu:latest
SHELL ["/bin/bash", "-c"]
RUN echo "export MY_VARIABLE=my_value" >> ~/.profile
RUN cat ~/.profile
RUN "source ~/.profile &&...
0
votes
1
answer
46
views
multiple call of exec > >(tee -a "${logFile}") 2>&1 with different log files
Look like if I call exec > >(tee -a "${logFile}") 2>&1 multiple times in the same script with different log files, the first log files will get appended multiple times. Is there ...
-1
votes
1
answer
71
views
Bash Flags are not passing through
I need help with this bash script please. For some reason, my flags are not being passed through. I'm using the unix getopts function,
Could someone take a look and let me know where I am going wrong?
...
0
votes
0
answers
13
views
Docker on Windows: OCI runtime create failed: unable to start container process: "bash": no such file or directory [duplicate]
I'm trying to run a Docker container on my Windows machine to execute some reformatting commands using poetry, isort, and black. Here is the relevant part of my Makefile:
.PHONY: reformat
reformat:
...
0
votes
0
answers
45
views
How to concat a string after a variable (exported) in shell script [duplicate]
I have two shell scripts.
SetEnvVariable.sh
MigrationOperator.sh
In SetEnvVariable.sh I'm setting a variable called CONNECT_POD_RESOURCE_NAME by doing below
export CONNECT_POD_RESOURCE_NAME="...
1
vote
1
answer
55
views
How to keep last few numbers of lines or last few numbers of bytes from each file of folder recursively and save with same name keeping hierarchy
I have logs folder under which there can be nested sub folders. I want to operate on each file recursively and keep last few bytes (tail -c) or last few lines (tail -n) based on configuration and ...
0
votes
1
answer
88
views
nohup has no effect when called from background service?
I have a java application which is running as background service on a ubuntu system. The application is running under root account and is started/stopped via systemctl. The application has an auto-...
0
votes
0
answers
63
views
reboot via script run by cron
I'm going nuts over something seemingly simple.
I want to run a script every minute which reboots when it finds something in a log.
It simply does not run via cron.
My script in /home/root/...
0
votes
1
answer
66
views
How can extract data single line from file and other process in each that line? [closed]
i have log file with contents inside. i.e file name is convert.20231010.log.
The content inside file as below
2024-05-17 00:14:02.447 Success ABCXYZ15 on hard disk
2024-05-17 00:14:02.447 Fail at /...
0
votes
0
answers
52
views
Hard Link is breaking with npm install
We had same code for windows and mac users and we use electron. So we create a separate package-win.json, package-lock-win.json for windows and package-mac.json, package-lock-mac.json for mac. Now ...