156,882 questions
Best practices
0
votes
1
replies
28
views
Bash tool/function to replace an arbitrary literal string (not regex) in a file/variable
I want to write a small tool or Bash function that can be used like:
tool foo bar file
and it should replace all occurrences of foo in file with bar.
The key problem for me: both foo and bar can be ...
Advice
0
votes
0
replies
15
views
How modify script with adding second task?
This script adds a line to add custom.js to vivaldi browser directory:
#!/bin/bash
vivaldi=/opt/vivaldi/resources/vivaldi
moddir=$HOME/vivaldi-modding/
sudo cp $moddir/custom.js $vivaldi
sudo sed -i -...
3
votes
3
answers
52
views
awk command to subtract constant from a column and print results
I was working on a one-liner to subtract a constant value (e.g. 100 in this case) from a specific column using awk. So far I can manage to get to where I can print the last iteration only – which ...
0
votes
1
answer
61
views
How to open a firefox tab in the currently open window
I created a script that is run by cron to open a tab in firefox. It will open a tab in firefox, but the tab is a new window. If I have firefox open, I need it to open in the same window that is ...
5
votes
2
answers
126
views
Hex escape sequences in bash regex range have no effect
Here is a bash script:
#!/bin/bash
char=$'\x01'
if [[ "$char" =~ ^[\x01-\x20\x7F-\xFF]$ ]]
then
echo "Unprintable"
else
echo "Printable"
fi
The script ought to say ...
1
vote
0
answers
54
views
Disable touchpad script fails while copied output works
I downloaded Fedora 43 Cosmic (Wayland) and found no way to disable my touchpad (mouse is always connected). xinput and synclient seem to be X11 only. Touchpad Disable is a simple checkbox with KDE ...
0
votes
0
answers
42
views
Sorting behaviour difference running bash script in a console session vs cron job
I have a bash script that I use to gather the usage stats of my storage volumes and email myself the results. Done so I can keep an eye on unexpected changes in disk usage.
The relevant code that ...
1
vote
2
answers
50
views
Loop in Background not listed in jobs
I have the following script, which should read the output from another command and then wait for changes, syncing these to a target directory. I replaced the actual commands with sleep and cat to make ...
Advice
0
votes
2
replies
33
views
How does nohup know whether I'm redirecting output to another file in bash?
My question is not about how to use nohup to redirect output. I've been using it for a while. Let me first state that I use bash. I know that by default, nohup my_command redirects stdout and stderr ...
0
votes
2
answers
56
views
Keep conda environment of parent bash session when start a new bash session
Suppose my current activated conda environment is py314 on Linux.
When I start a new bash environment from the current one,
no matter via command bash, screen, or start vscode from command line,
the ...
0
votes
0
answers
58
views
git-bash gettext wrong encoding
I'm trying to translate my bash scripts using the gettext tools but I have a problem where the encoding seems to be wrong.
Let's say I have the following file called fr.po:
# French translations for ...
0
votes
1
answer
92
views
Fortran90 doesn't compile with gfortran
I am attempting to compile and run a Fortran 90 program using command line (bash). In the past, when I've run gfortran /path/to/file, a file a.out and a file program_name are created, and I can run ...
Best practices
0
votes
0
replies
38
views
When packaging a bash binary produced by Bazel, do I need to keep the rlocation/data location boilerplate?
I was trying to exercise with Bazel by packaging a deb package from a collection of scripts I'm writing to automate a few tasks at work. Right now, I keep them either in /usr/local/bin or \~/.local/...
Best practices
0
votes
1
replies
32
views
Best way to check for empty secret/variables in GitHub workflows
We've had troubes in the past trying to validate github environment against unset/empty secrets or variables. I've used bash scripts like [ -z "${{ secrets.mysecret }}" ] && exit 1; ...
1
vote
0
answers
74
views
Prevent TMUX exit on PTY OOM kill?
I have a high memory program (ML) that I want to run in a tmux session. However, if the process is OOM killed, the tmux session is also shut down. I partially solved it (using the below run-bg), but ...