156,847 questions
0
votes
1
answer
47
views
Why doesn't ignore option for ls work in this instance? [duplicate]
I have a program like this (the indented lines can be run multiple times):
#!/bin/bash
options=""
options+=" --ignore={"
read pattern
options+='"'
options+="$...
3
votes
3
answers
55
views
How to do console colors in bash script
I have a Bash script that prints status headers using ANSI color escape codes. The script runs, the output prints, but instead of seeing colored text, I see the literal escape sequences printed to the ...
3
votes
2
answers
103
views
use while with multiple variables in the condition
When I add more than one variable in a while loop condition, the loop behaves unexpectedly.
cat script.sh
#!/bin/bash
string=Db6laokfKc
echo $string
klen=`echo -n "${string}" | wc -m` #10 ...
Best practices
0
votes
6
replies
89
views
using sed to replace multiple lines between two patterns
I have a file example.txt with the following content:
Begin of file
BEGIN
1
2
3
4
5
6
7
8
9
10
END
End of file
I want to replace every second line inside a matched space of sed. So I tired
cat ...
0
votes
0
answers
57
views
How do I use the Terratest shell module? [closed]
I’ve been trying to use the Terratest shell module to execute bash commands, but I haven’t had much success. Documentation appears to be limited, and most references I found were via AI tools. Below ...
-5
votes
0
answers
45
views
How to unfreeze the terminal in VSCode after CTRL+S? [closed]
I want to disable Ctrl+S in VSCode.
It's not that I want to pass CTRL+Q to bash.
How to unfreeze the terminal in VScode after CTRL+S?
Advice
0
votes
9
replies
89
views
Shell substitute/show variables from one variable
The task is to show line with variables from one variable (substitute like echo "${!VAR_NAME}" but for multible variables at once)
i e g
l=$(head -1 "$table") #this header can vary
...
Advice
0
votes
6
replies
74
views
Parsing pipes with boolean logic operators in bash
I'm investigating how Bash parsing works. Let's assume that all lower-case letters here represent scripts that always return a successful exit status - 0. The contents of all scripts are identical. ...
3
votes
7
answers
225
views
Generate all versions of a string with each letter replaced by a wildcard (?) once in bash
I am using grep to look for strings (sequences) in a fastq-file and extract matching reads (lines).
Since grep only finds perfect patterns, I was wondering whether it is possible in bash to generate a ...
-4
votes
1
answer
108
views
How to rename many files with a ID_suffix name to prefix_ID? [duplicate]
I have hundreds of files on the following format
20100110_test_file.sas7bdat
20100210_test_file.sas7bdat
20100310_test_file.sas7bdat
20100410_test_file.sas7bdat
I need to change the format all those ...
-1
votes
0
answers
29
views
Duplicate primary key errors when applying binlog after mydumper/myloader restore [migrated]
I am implementing a full + incremental restore workflow using mydumper / myloader and MySQL binary logs.
Backup step
I take a snapshot-consistent backup using mydumper:
mydumper \
-u Admin \
-h ...
3
votes
1
answer
171
views
Bash date calculates time addition incorrectly
I am writing a simple bash script for computing time and date by adding seconds onto a random date that I give. It worked fine so far but going from 2016-03-13 00:00:00 to 2016-03-13 03:00:00 skips ...
0
votes
0
answers
103
views
Why does this bash script not execute the commands sequentially? [duplicate]
Given:
#!/bin/bash
set -x
cat <<EOF | while IFS= read -r LINE; do "${LINE}"; done
/usr/bin/bash
pstree -u "${USER}"
EOF
It outputs:
$ ./cat_while_bash.sh
+ cat
+ IFS=
+ read ...
3
votes
3
answers
166
views
Reading desktop notifications from the command line. Debian/Ubuntu
Running Ubuntu 24.04lts.
NOTE: I am trying to read the notification sent by he Discord app to my personal desktop notifications. When I notification from a specific sender, with a specific message, I ...
0
votes
1
answer
76
views
"...SSH Permission denied (publickey,password,keyboard-interactive)" when running python script as service on raspi [closed]
I have a python script that runs as a service on raspi, the script executes a bash script which then connects to a windows pc via SSH using a key.
I have successfully use the same code to connect to ...