Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
81 views

I can't figure out why this code outputs VAR= when it should output VAR=val. Any ideas? #!/usr/bin/env bash arr=( "export VAR=val" "echo VAR=$VAR" ) for it in "${arr[...
niXman's user avatar
  • 93
0 votes
1 answer
80 views

below is a bash script that works fine tested in my terminal the sound is played but when it is actually ran in a cron scheduled task there is no sound only the dialog is shown #!/bin/bash export ...
k1dr0ck's user avatar
  • 1,277
0 votes
0 answers
85 views

Associative array appears to behave differently when nullglob is set: shopt -u nullglob unset aya declare -A aya aya["10"]="hi" echo ${#aya[@]} unset aya["10"] echo ...
programmer's user avatar
1 vote
1 answer
101 views

Goal Execute long running command remotely with the following capabilities: We can kill the task with its PID If task completes, its exit code should be written to file Task should be detached from ...
Kungfunk's user avatar
  • 115
0 votes
0 answers
66 views

I have a bash script where I use the read command twice: 1st usage: read text file line by line 2nd usage: asking user in the loop to confirm something However, the second usage is completely ...
zappee's user avatar
  • 23.2k
1 vote
1 answer
85 views

When I set a DEBUG trap in Bash like this: set -o functrace trap 'echo "# $BASH_COMMAND" >&2' DEBUG Suddenly, this function stopped working: getBase() { local base="$1" ...
Maestro's user avatar
  • 9,876
1 vote
2 answers
178 views

I have this profile settings.json: { "terminal.integrated.profiles.osx": { "python-venv": { "path": "/opt/homebrew/bin/bash", ...
Kenny83's user avatar
  • 931
-10 votes
4 answers
209 views

i need Python's os.path.join function in Bash it should be implemented as a pure Bash function with zero dependencies on external tools like sed on error, the function should return 1 but it should ...
milahu's user avatar
  • 3,758
0 votes
2 answers
154 views

From a command I want to redirect stderr to tty and stdout+stderr to a file. How can I do that? e.g. for this: cmd.bash #!/usr/bin/bash echo "Hello World" echo "this is an error" &...
glades's user avatar
  • 5,374
-4 votes
2 answers
117 views

I want to edit a file in a single command to append a line and remove first lines if more than N. The furthest I got was to use sed: sed -i -e "\$a\[$(date '+%F %T')] $1" -e :a -e "\$q;...
hazardous silence's user avatar
0 votes
3 answers
134 views

I have this part of a script which worked for a couple of weeks, but now stopped working: find /media/2C1F-444F/usb_musik/newMusik -type f -printf '%T+ %p\n' | sort | head -n 5 | awk '{print $2}' | ...
syswombat's user avatar
1 vote
2 answers
118 views

This example is from AI, but it doesn't appear to work. Before sending it as a bug to the gnu bash team, I would like to validate that this is a bug. If I declare a set of associative arrays such as ...
OldguardMD's user avatar
0 votes
1 answer
70 views

i add nacos-plugin to nacos-2.0.3,but when i create images error,i modify dockerfile, when i build nacos ,occur pring.config.name=application,custom --logging.config=/conf/nacos-logback.xml --server....
QingHan Kong's user avatar
-2 votes
1 answer
102 views

I've written a script to reboot my router every other day. It works as intended when I test it out manually but doesn't work properly in cron. #!/bin/bash c=$(ls -a /tmp | grep -o ".daycount*&...
Mike's user avatar
  • 7
5 votes
1 answer
80 views

Kindly consider the following dockerfile that uses bash image and runs a bash to trap QUIT and then shows that QUIT trap. It should show the string "something". ARG VERSION=latest FROM bash:$...
KamilCuk's user avatar
  • 146k
0 votes
2 answers
94 views

I have searched everywhere but could not find a solution hence posting here. Partclone prints the status / progress on the same line and it keeps updating this line, I want the progress to be ...
user2107349's user avatar
2 votes
1 answer
77 views

I am using the following Bash script. What I don't understand is why the parent PID and the current PID are not matching. For example: #!/bin/bash my_background_function() { echo "Starting ...
dan's user avatar
  • 41
1 vote
2 answers
111 views

I have 2 files of data and I'd like to add data from one file to the other, but rather than appending to the file as a whole I'd like to append line-by-line. E.g. I have: ip.txt 192.168.0.10 192.168.0....
thirstyice's user avatar
0 votes
1 answer
170 views

SOLUTION: Got rid of the --header flag, added json= to the beginning of the data set. I'm attempting to update some settings in a qBitTorrent Docker container via the WebUI's included API. I've ...
tambourinecenter's user avatar
4 votes
1 answer
85 views

I have a small script to run a node.js server and open it up on the browser right after, problem is that if I close the terminal that this creates, the server keeps running in the background of my ...
DATA's user avatar
  • 43
1 vote
1 answer
106 views

I'm building a SLURM pipeline where each stage is a bash wrapper script that generates and submits SLURM jobs. Currently I'm doing complex job ID extraction which feels clunky: # Current approach ...
desert_ranger's user avatar
0 votes
1 answer
92 views

I've tried to build a shell script that iterates through all possible XOR obfuscations of a string within a DOS binary executable, parsed using radare2 in hexadecimal, and find it. Am I doing this ...
Rezzy-dev's user avatar
1 vote
2 answers
125 views

Problem: How to get a slice of a bash array's indices? $ array=('a' 'b' 'c' 'd') $ echo ${array[@]:0:2} a b $ echo ${!array[@]:0:2} bash: a b c d: invalid variable name What is exactly happening in ...
Feasuro's user avatar
  • 31
-1 votes
2 answers
195 views

Mid-switch to Linux I realized I've a large personal and work archive that has over 1100 Windows Shortcuts(.lnk) of both files and folders and it is unusable without them and have been trying to ...
h4g3-Lawson's user avatar
-2 votes
1 answer
103 views

in a terminal mpc status | awk 'NR==1' $ mpc status | awk 'NR==1' Ramones - Pet Sematary would show me which song is playing how to keep this as a variable to use it later? found in the net some ...
syswombat's user avatar
2 votes
5 answers
114 views

I am playing with text automatically converting to markup. I can make sed enclose some inline code: echo "this is inline_code test 1_2 (_)" | sed -re "s/([a-z0-9]+_[a-z0-9]+)/\`\1\`/g;s/...
thomas's user avatar
  • 256
2 votes
2 answers
188 views

I wrote a simple quick sort algorithm. When I run it, it echoes the same array back. #!/usr/bin/bash arr=(1 8 3 9 4 5 7 2) partition() { local low=$1 local high=$2 local pivot=${arr[low]}...
Hi Byee's user avatar
  • 25
0 votes
1 answer
67 views

I thought I understood -e but unless this inconsistency is a bug then I don't... bash --version # GNU bash, version 5.2.32(1)-release (x86_64-unknown-linux-gnu) cat >set-e-exit.bash <<'EOF'...
boscadubh's user avatar
-1 votes
0 answers
35 views

At my workplace, VMs I SSH into require 2FA. Until I run ssh-copy-id, they also require a password. Currently, I have a script that runs ssh-copy-id then ssh, which results in two 2FA if I've copied ...
everetttttttttttt's user avatar
2 votes
4 answers
162 views

I'm learning bash from a book and just wanted to see if there is a more efficient way to do this. The output of cat /proc/acpi/wakeup is multiple lines, but I only care about this one: GPP0 S4 ...
dbaser's user avatar
  • 327
1 vote
1 answer
130 views

I'm trying to implement simple wrapper for find to find files, links or both. Here is path of my code: typeArr=() if [[ "$type" == "f" || "$type" == "l" ]]; ...
Grammatikati Konstantin's user avatar
1 vote
2 answers
84 views

I am trying to batch-encrypt a set of PDFs using qpdf. This works fine in a shell for loop: for f in *.pdf; do qpdf --encrypt "" "" 256 --print=none --modify=none --extract=n --...
nicholaspooran's user avatar
1 vote
1 answer
148 views

I would like to use set -o vi in my terminal. However, I find myself getting confused on whether I am in insert mode or normal mode, since the cursor does not switch between a vertical line (insert) ...
luna's user avatar
  • 13
1 vote
2 answers
123 views

I'm trying to read 2 lines into two bash variables but those lines contain spaces. Here is how those two lines are generated : $ url=https://www.youtube.com/watch?v=c5U4D-Hn5Vg $ yt-dlp --no-config --...
SebMa's user avatar
  • 4,965
0 votes
1 answer
115 views

I have a binary sample (VirusShare_00238010bb86fd0bf4014c3d19f114b2) used in my research that behaves oddly when I try to measure its runtime When I run it directly with /usr/bin/time, it exits almost ...
Robert's user avatar
  • 1
0 votes
1 answer
88 views

Pulling my hair out, looping over 100K S3 files in AWS Cloudshell; to copy in place to kick off a file processing lambda. when I run my for loop with an aws s3 cp on the dataset I want to, the for ...
areeekay's user avatar
2 votes
0 answers
38 views

csh and tcsh use the syntax $?var to test whether a variable is set or unset. $?var or ${?var} expands to 1 if $var is set (even if it's set to the empty string), or to 0 if it isn't. This 0 or 1 ...
Keith Thompson's user avatar
1 vote
1 answer
90 views

I tried to figure out how to replace a string variable to '*' a="bamtools/*/*bam_metric.summary.tsv" ## not working echo ${a/*\*/} I would like to see bam_metric.summary.tsv after ...
Jack Z's user avatar
  • 33
0 votes
2 answers
86 views

If you run: stat /etc/fake_parent/fake_folder/fake_file then stat will report "No such file or directory". But if you run: stat /etc/sudoers.d/fake_folder/fake_file then stat will instead ...
dln385's user avatar
  • 12.2k
0 votes
1 answer
97 views

the start of my script is: for i in **; do FileName=$i FileType=$(stat -c %f "$i") if [ "$FileType" = "41ed" ]; then FileType="D" else ...
bart.h's user avatar
  • 9
0 votes
4 answers
183 views

I have a bash script that uses a space-delimited string to keep track of all the possible valid arguments: FRUITS="apple orange pear banana cherry" I use a bash case statement because some ...
NateT's user avatar
  • 312
1 vote
0 answers
48 views

Given: #!/bin/bash #SBATCH --account=project_XXX #SBATCH --job-name=test #SBATCH --output=/scratch/project_XXX/ImACCESS/trash/logs/%x_%a_%N_%j_%A.out #SBATCH [email protected] #SBATCH -...
farid's user avatar
  • 1,621
-3 votes
1 answer
103 views

Here's my current preferred method that I normally put at the top of functions: #!/usr/bin/env bash unset opts args for arg; do [[ ${arg:0:1} == "-" ]] && opts+=("$arg") || ...
mrkbutty's user avatar
  • 609
3 votes
4 answers
179 views

I was making a script for a challenge I saw a while ago, which asks: "extract the 2nd ASCII character from every line in input if the line characters are less than 7, 2nd and 7th if more", ...
the_fearless_knight's user avatar
0 votes
1 answer
67 views

mkdir ./output for year in {1990..2025} do mkdir ./$year \n for week in {1..52} mkdir ./"$year"/"$week" \n done done gives syntax error on second call of mkdir ...
Jan Hackenberg's user avatar
-2 votes
1 answer
73 views

This script behaves perfectly fine on a real Ubuntu system. #!/bin/bash set -Eeu -o pipefail word1=$(awk '{print $2}' eff_short_wordlist_2_0.txt | fzf) echo "${word1}" word2=$(awk '{print $...
Wisteso's user avatar
  • 384
1 vote
1 answer
69 views

Try doing the following: echo '/C=UK/' This will output /C=UK/ literally. However, if I try using it in a program... openssl req -subj '/C=UK/' (...) Then I get the following: req: the ...
npr_se's user avatar
  • 91
2 votes
4 answers
148 views

I am trying to write a BASH script that will issue commands to ADB to remove packages from a list of packages in a file. However, my script leaves the loops that iterates over the file if the script ...
natS's user avatar
  • 71
0 votes
2 answers
76 views

I'm in the process of creating a bash script. I need input from the user. Here's a snippet: printf "Press$red Y$green to continue,$red N$green to Abort,$red D$green for Dry Run or$red H$green ...
bart.h's user avatar
  • 9
1 vote
1 answer
125 views

After I enter command in an interactive bash terminal, e.g. foo | bar, I want to automatically and silently run a script after, e.g. my_script.py "foo | bar". I can almost do this with ...
meisel's user avatar
  • 2,615