All Questions
Tagged with shellscript or shell
92,956 questions
2 votes
1 answer
88 views
How to properly quote associate array subscripts in Bash?
If I declare an associative array in Bash, and then want to reference an element using a subscript which is a variable whose value contains spaces, when and how should I quote the variable name I am ...
2 votes
0 answers
80 views
How to include feature of using arrows to navigate through previous commands [closed]
I am making a shell orchestrator in C which connects with other devices and controls connected systems using an IP address. I am having difficulty in adding the feature to use arrow keys to navigate ...
Advice
0 votes
9 replies
52 views
Most efficient way to determine if a file exists only with a given extension
I have a little problem to crack that turns out to be less trivial than I thought - even to formulate as a question for the title of this ticket, in fact! Here's the background: I mount my iPhone via ...
2 votes
1 answer
102 views
Receive "Error reading input file" when running password decryption in BASH
When working on a BASH exercise that is about building a simple password and account manager, I am required to add the function that allows users to retrieve an encrypted password. Below are my codes: ...
3 votes
1 answer
70 views
time shell keyword not respecting value of TIMEFORMAT when set before command
According to the Bash manual, The TIMEFORMAT variable may be used to specify the format of the time information. For instance, if I set TIMEFORMAT to %R, then time should only print the elapsed time ...
1 vote
1 answer
110 views
chdir syscall doesnt change my current directory
I am trying to implement a small Shell in C, one of the builtins required by my school project is cd. To do it, I use chdir to get a grip on some basics directory movement. I have read the man of cd ...
Advice
0 votes
1 replies
47 views
How to design a database schema for managing hospital medical equipment inventory?
I’m working on a small project to build an inventory management system for hospitals that keeps track of medical equipment and supplies. The goal is to manage different types of equipment, track stock ...
0 votes
1 answer
48 views
Handle leak when using WScript.Shell / FileSystemObject via COM automation (Windows Server 2022)
I am investigating a possible handle leak related to Windows COM objects used from a third-party application. The application (Elipse E3 SCADA) runs VBScript code that instantiates Windows COM objects,...
0 votes
0 answers
52 views
Check if shell script/function is being piped into without false positives [duplicate]
I've searched around about how one can write a shell script (preferably cross-shell, but also in bash) that detects if it is being piped into so that it's operation can be changed accordingly. The ...
0 votes
0 answers
69 views
Piping into interactive shell
I need to issue a lot of, say, wget commands manually. I figured the following would make it convenient: $ sed 's/.*/wget &/g' | bash -i Indeed, stdin is now listening to my input as I copy-paste ...
Advice
1 vote
11 replies
131 views
Which shell is it actually?
I’m a macOS user and I use the Terminal while studying programming. I’m not sure whether I should be using bash or zsh. When I type bash, it switches to bash and the top bar shows “bash”, but when I ...
2 votes
1 answer
160 views
Is the way bash evaluates this subshell with `set -e` a bug?
Since the subshell in the last line fails, I would have expected to see a fail. Am I missing something or is this a bug in GNU bash, version 5.3.3(1)-release (x86_64-pc-linux-gnu)? $ false; echo $? 1 $...
0 votes
0 answers
85 views
line 0: undefined variable: u - How to make shell not interpret gnuplot variable?
#!/bin/zsh for i in $(ls rid_*.xvg | sort -V | head -n1) do echo ${i} gnuplot <<- EOF reset session FILE="${i}" set yrange [0:30] # Gaussian function g(x)=...
2 votes
3 answers
119 views
How to iterate over a number in bash through one variable and assign output to a variable?
I am trying to generate a script that gets the number of keywords, asks you for each keyword, and assigns each one in a variable to a for loop, I have tried this so far: #!/usr/bin/env bash read -p ...
2 votes
1 answer
76 views
shebang: run unbuffered python as other user for real-time output redirection
TL;DR I just want to run arbitrary shell commands with a static service user and see their output on the shell but also capture it for later use, i.e. send it by e-mail, and observe redirected output ...