156,830 questions
-1
votes
0
answers
17
views
How can I install angsd on a linux platform? [closed]
I'm trying to install angsd for running paired-end screening data analysis and after git clone and going into the folder, when running the command make, I keep getting the following error:
kprobaln.c:(...
-1
votes
0
answers
58
views
.NET Template - How to automatically run git init and initial setup script after template creation?
I've created a custom .NET Template for Clean Architecture and I want to automatically initialize a Git repository and run setup scripts after the template is created.
Current Setup
This is my ...
3
votes
1
answer
84
views
Are contents within parentheses executed last?
I came across this line in my homework:
(cat "$@" 2>&1 >&3 | tr a-z A-Z >&2) 3>&1
Is the 3>&1 executed first to create a file descriptor 3 pointing to ...
1
vote
3
answers
128
views
Why does sorting reduce the time of my function?
This calculation
time { < <(seq 0 20000) readarray -t array ; }
takes 0.309 seconds on my computer.
But this:
time { < <(seq 0 20000|sort) readarray -t array; }
takes only 0.074 seconds.
...
-4
votes
0
answers
31
views
How to access env values defined in a docker container [duplicate]
Introduction
I want to reference the env values defined inside docker container. I want them to be able to them in bash CLI and in bash scripts.
Problem
However, referencing them like $MY_ENV, ${...
-2
votes
0
answers
92
views
sed to copy citations, help removing quotation marks [closed]
I use a bash script to copy citations from Zotero to Obsidian.
I trigger the script via a hotkey, however, the sed command also works if you have it in a terminal, then copy the citation to the ...
1
vote
2
answers
66
views
How do I return the PID of an osascript call from within a function (or how do I create a persistent notification I can kill later in the script)?
I'm using Bash 3.2 in macOS Tahoe. I've hacked together this function to show an informational dialog:
showDialog(){
local strDialogText=$1
local intDialogSeconds=$2
IFS='' read -r -d '' strJS <&...
Advice
0
votes
2
replies
39
views
Assignment on DevOps Engineering class
Please who can explain and guide me on this assignment thank you.
We walked through examples of all 10 labs during demos. Complete them on your local machine to solidify everything:
Hello World ...
-2
votes
0
answers
37
views
Is it possible on X11 to switch workspaces with 1/2/3/4 ONLY if the key is not used by the focused app? [closed]
I’m using Parrot OS with the MATE desktop on X11.
What I want:
- Press 1/2/3/4
- If the focused app actually uses the key (typing in terminal, browser input, editor, shortcuts, etc) → let it behave ...
-1
votes
1
answer
76
views
Why does my Bash script create two symlinks to the same file, but in different places? [closed]
A little background. I work across multiple systems and so I would like a way to make life a little easier keeping all the basics in sync. My idea was to create a folder called ~/common_files/, put ...
3
votes
5
answers
188
views
`printf` and `xargs` in a `for` loop
I want to produce this output:
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
For that I created this script:
(Based on https://stackoverflow.com/a/23961301/22133250)
...
1
vote
1
answer
126
views
Is there a difference between 'eval' and sourcing a temporary file?
These two examples accomplish the same thing:
# using eval
var=hello
eval "some_func() { echo $var; }"
some_func # "hello"
# using source
var=hello
source <(echo "...
Best practices
1
vote
2
replies
34
views
Why does variable expansion behave differently with sudo -i compared to nested bash -c?
I'm trying to understand how variable expansion works across multiple shell levels, particularly when using sudo -i versus nested bash -c commands.
Background: Nested bash -c behaviour
First, let me ...
0
votes
1
answer
58
views
`npm run` used within VS Code can't find an executable I have verified exists. Why not?
Using VS Code on Linux Mint, I'm trying to npm run a bash script from within VS code, but I get an error;
ls: cannot access '/usr/bin/convert': No such file or directory
The terminal process "/...
0
votes
0
answers
39
views
How to restart CKAN processes (but not jobs/worker) inside running ckan-docker dev container?
I’m developing CKAN extensions using the official ckan-docker setup with the dev images and need to restart CKAN after various updates in my extension.
Inside my main ckan container (run via ...
7
votes
6
answers
536
views
Extract selected data from multiple lines of text
Here is the output of my curl command (print headers only):
HTTP/1.1 200 OK
Server: CacheHTTPd v1.0
Date: Thu, 08 Jan 2026 19:21:11 +0000
Content-Type: application/octet-stream
Content-Length: ...
3
votes
1
answer
117
views
How can I loop through a JSON file using bash and extract values to variables?
I have a json file, vars.json, of arbitrary length, in a format like
[
{
"environment1": {
"variable1": "Value1",
"variable2": "Value2&...
0
votes
1
answer
49
views
How to escape starting new line from amidi dump to pass it in a while read loop in bash
After a lot of tests and researches I can't find how to solve this.
I am working on a midi controller adaptation for vlc on linux and I have a simple but annoying problem: on my event listening with ...
-3
votes
1
answer
83
views
return value from a vimscript to a variable in calling bash script [closed]
First off, allow me to apologize for the confusion this question has created, and for my tardiness in responding. I live completely off-grid, and can only access internet at the library when I come to ...
0
votes
0
answers
30
views
How to interrupt bash with all its subshells and spawned tasks [duplicate]
Given this script kill.sh:
#!/usr/bin/env bash
for i in 0; do
sleep 1111
done &
pid=$!
trap 'echo killing $pid && kill $pid; exit' INT
sleep 2222
$ ./kill.sh
^Ckilling 25190
But the ...
4
votes
2
answers
112
views
get last modified year from a file in an sftp server
I am downloading a file weekly from an sftp server.
The filenames are random so the only way to identify the new file is to use the system metadata to find the last modifed time of the files.
I can ...
2
votes
3
answers
156
views
How to extract the correct server version from a MySQLDump?
We are creating docker images from MySQLdump from all kind of systems and try to extract the DB version via Regex from files like this:
-- Server version 10.11.8-MariaDB-0ubuntu0.24.04.1
$ echo &...
Tooling
0
votes
14
replies
225
views
simple/fast way to transfer files from Linux to Windows
I have two computers. One with Arch Linux installation with any modern software. Another with 32bit Windows 7.
My goal is to transfer around 100GB of files from Linux to Windows. I have USB 3.0 to ...
0
votes
1
answer
87
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
116
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
3
answers
150
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
1
vote
8
replies
145
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 ...
Advice
0
votes
9
replies
95
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
79
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
287
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
109
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 ...
3
votes
1
answer
177
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
105
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
212
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
113
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 ...
2
votes
1
answer
64
views
GRUB audit script always fails on Ubuntu even after remediation (AppArmor parameters not detected)
I am trying to implement a CIS hardening rule on Ubuntu that requires every GRUB linux entry to include:
apparmor=1
security=apparmor
Audit script
#!/bin/bash
if grep "^\s*linux" /boot/grub/...
Best practices
3
votes
2
replies
116
views
How to efficiently bulk download from the internet archive
I want do download certain search results from the internet archive. I would like that the names of the resulted files and directories to be the title of the work -- idealy YYYY_<author>_<...
-1
votes
1
answer
135
views
How to give root access to Java Runtime Process? [closed]
I am trying to run a bash command through Java.Runtime.exec(), specifically coredumpctl.
I am only able to run the command on a bash terminal when I login as a root user, and this doesn't seem to be ...
2
votes
1
answer
192
views
How to do nothing with "for in" in Bash? [closed]
for in in Bash is setting variable. I need only the variable itself from this command.
for VAR in FILE*; do
something (hate it)
done
I plan to use this variable later, not in the block itself. Just ...
Best practices
2
votes
10
replies
212
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 snippet that can be used like:
tool key value file
and it should replace all occurrences of key in file with value.
I tried:
sed -i "s/${key}/${value}/g"...
Advice
0
votes
1
replies
54
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 -...
6
votes
4
answers
220
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
98
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
169
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
1
answer
91
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 ...
1
vote
2
answers
62
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
3
replies
48
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
70
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
78
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
150
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 ...