Questions tagged [bash]
Bash is a free shell for Unix-like operating systems from the GNU Project.
11,762
questions
0
votes
1
answer
39
views
pipefail over ssh in linux
set -o pipefail is not getting evaluated correctly on the remote host if the set command is used in ssh command.
Example
ssh hostname "set -o pipefail; false | true; echo $?" - gives 0 (Not ...
1
vote
2
answers
365
views
How to use the `tax[13]-eq-dc` regex in a Bash loop?
The following regex tax[13]-eq-dc represents two servers, tax1-eq-dc and tax3-eq-dc.
I'm trying to find a way to use it in a Bash do loop, but can't just get the correct syntax.
E.g., the following is ...
0
votes
0
answers
273
views
Permission denied error when trying to SSH through a script
I have a set of Bash scripts designed to establish an SSH connection from a local machine to a remote server through a middle server. The local script initiates a tunnel using socat, and the middle ...
2
votes
2
answers
145
views
How to convert lscpu output to JSON format with no trailing spaces?
I tried to convert it to the JSON format by -J flag, but older lscpu versions have no such functionality.
The solutions I've found here didn't help me.
I want to put out here the solution I got from ...
0
votes
0
answers
64
views
duplicate pane to show history in tmux
Sometimes, the output of a command is very long and thin, and my screen is much wider than it is tall. Is there any way to make a new pane which is a copy the current one, but more scrolled up so that ...
3
votes
1
answer
347
views
Debian Bash Associative Array Self (Internal) Referencing
I'm attempting to contruct an associative array where key-value pairs within the array, reference other key-value pairs in the same array, using Debian Gnu-Linux 12.4, 22.12.3 and Bash 5.2.15.
Example,...
1
vote
1
answer
256
views
How to put more than one image by page using img2pdf?
I have a series of images (>100) that I want to print in a specific size, that size let me put 8 of the images in a page, but when running the next command I get one image by page.
img2pdf *.png --...
0
votes
0
answers
181
views
How to remove left-over files from an Homebrew installation
My current homebrew has its files installed in /opt/homebrew which is correct. However, I have several hundred leftover homebrew files in /usr/local/Cellar which are still symlinked to in /usr/local/...
2
votes
0
answers
101
views
Program is not interactive in NuShell
Some background
Qemu has a wonderful feature, which allows you to connect its stdio streams to serial ports on the guest. This allows you to connect QEMU's stdio streams to a TTY shell on the guest ...
0
votes
0
answers
1k
views
Bash - node: command not found when being run in a shell script
When trying to run a node command from a .sh script I get the error node: command not found, however I can see that node is installed, running node -v shows me my current version, what could be the ...
0
votes
1
answer
444
views
docker login fails when done in .bashrc
At the end of my .bashrc file I have the following:
docker login -u AWS -p $(aws --region us-east-2 ecr get-login-password) 636602586062.dkr.ecr.us-east-2.amazonaws.com
However, whenever I open up a ...
0
votes
0
answers
38
views
How to stop backup being deleted as soon as it is completed?
Duplicity full backup via ftp completes, then is deleted, all with no user action.
There are 2 things I would like to know;
is there anything in the information below that explains this problem?
...
0
votes
1
answer
251
views
google-chrome, when ran in the background through bash, still outputs errors, despite 2>&1 > /dev/null
When I run google-chrome 2>&1 > /dev/null & and then go back to the prompt and then visit a website with, say, an invalid cert, I still get errors output to my console's screen. eg.
...
0
votes
0
answers
65
views
Is it possible to use the signalstats YAVG filter in FFMPEG to control the gamma correction in a video?
I don't know if this is even possible, but something tells me it is… You see, I want to dynamically control the gamma correction in FFMPEG/FFPLAY depending on how bright/dark the frame being ...
2
votes
2
answers
676
views
What is the command line shortcut to uncomment a previously commented line?
Alt+Shift+3 can only comment out, on subsequent invocations simply adding multiple comment characters (hashes) instead of toggling on / off the comment. How to uncomment a previously commented line or ...
0
votes
1
answer
99
views
Output of atool -l for large archives
The command atool -l my_archive prints the directory structure and files of my_archive to the command line. This is very handy if the archive contains only a few files. However, if there are many ...
2
votes
2
answers
186
views
Debian Bash Readonly Associative Array Error Redirection
I've declared a readonly associative array in a script file on Debian Gnu/Linux (version 12.4).
As with a readonly variable, error redirection is easily done as such,
readonly AQUA_FG="$(tput ...
2
votes
1
answer
297
views
How to Print, when columns have spaces - awk?
Problem:
desired columns have text with spaces SAMSUNG MZNLN128HCGR-000H1
undesired columns have text with spaces, see VENDOR = M.2 SSD
awk only printing the first word.
awk not printing the column ...
0
votes
1
answer
82
views
What command to force dd output to a fixed width of 90 characters?
using:
neofetch --stdout |grep 'OS:'
OS: Kubuntu 22.04.3 LTS x86_64
dd --version
dd (coreutils) 8.32
Background:
re-purpose a disk = objective
some script is being developed
some script will delete ...
1
vote
1
answer
72
views
GNU "parallel" how to achieve tee behaviour
Is it possible to use gnu-parallel to run multiple commands which all read from stdin?
For example:
echo 'hello world' | parallel --keep-order --tagstring 'Part {=$_=uc($_)=}:' --pipe "cat" :...
0
votes
1
answer
47
views
How do I tell sed to stop trying to process commands?
Maybe I'm an idiot (this is the likely scenario, and I'm new to sed/bash scripting), but why does this work:
NewVersion="$(echo $NewVersionFile | sed 's/^.*-\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/')&...
1
vote
1
answer
327
views
Shell command to tar directory excluding certain folders
In Bash 4, I want make a tar.gz with excluded folders, and while tons of answers about this simple case exist, nothing works in my case.
I would like to keep the directory mentioned in exclude, ...
0
votes
1
answer
70
views
can Clear-Content be equivalent to bash 'truncate'?
This could be off-topic, if so my apologies; please re-direct me to the correct StackExchange site.😉
Can Clear-Content file.log be used in Powershell, on a Windows Server environment to empty a ...
0
votes
1
answer
33
views
Using mlocate to search on multiple systems in parallel
I often need to search files on different systems, without knowing on which system the file I'm looking for is located.
Is it possible to search with mlocate on multiple systems in parallel? By ...
1
vote
1
answer
243
views
Why is this tmux option not persisting?
I would like to generate a bashrc configuration file each time I start a particular tmux session, and I want to use my user's default tmux configuration file ${XDG_CONFIG_HOME}/tmux/tmux.conf as well. ...
1
vote
1
answer
482
views
What's the difference between git-bash.exe and bash.exe and how they interact with Windows Terminal?
I've installed Git for Windows.
I want to run git-bash in a Windows Terminal tab.
I initially configured a git-bash profile, in Windows Terminal, whose Command Line field I populated with C:\Program ...
0
votes
1
answer
1k
views
"ls: cannot open directory '.': No such file or directory" in Git Bash (in VS Code terminal)
I am working in a Git Bash terminal within Visual Studio Code. For some reason, when the behavior of the terminal changed so that if I execute ls, the result is
ls: cannot open directory '.': No such ...
0
votes
1
answer
108
views
Overwrite bash alias for git pull to include --recurse-submodules
Neither functions seem to affect anything for me? Is anyone able to get them working and show me what I'm doing wrong?
I'm trying to override git pull to include recursive submodules whilst keeping ...
0
votes
2
answers
317
views
Echo the exact command used to start a Bash script
I'd like to give feedback to the user of a bash script along the lines of "You've run the following command <exact command the user entered>, better to run it like this <better command&...
0
votes
2
answers
97
views
How to force declare -f to respect semicolons
Given the function
hello () { echo "one"; echo "two"; }
Inside a script I'm using cmd="$(declare -f hello); hello" then I try executing the command using bash -c $cmd, ...
0
votes
0
answers
465
views
Bash Script to Detect Monitor
I am trying to write a bash script to detect a monitor. I was able to find it with Xrandr but am not sure if this is the right method and unsure how to get the terminal to open in designated monitor.
...
0
votes
1
answer
151
views
How to convert code from test format to if fi format?
I have code that opens a bash file in a terminal for entering the sudo password:
test "$IN_TERM" || {
export IN_TERM=1
konsole -e "$0"
exit 0
} && true
I need ...
0
votes
1
answer
98
views
Tmux conf returns error at start
I ssh to a remote server with TMUX. The .tmux.conf file is very simple:
setw -g mode-keys vi
set -g status-right '#(TZ=Asia/Kolkata" date +"%%Y-%%m-%%d %%H:%%M")'
And the relevant ....
3
votes
0
answers
222
views
Is there a good way to write a shell script compatible with both bash and zsh that addresses array elements?
The fact that bash is 0-indexed and zsh is 1-indexed can cause problems. For example the following will work as intended with bash, but not zsh (PS I am aware that I don't NEED to use an array for ...
0
votes
0
answers
160
views
How to run sh script in lxterminal using double click on Raspbian
I've read so many threads regarding running a script using double click, but none of the ways describes my case.
My operating system is Raspbian Bookworm (Debian), the graphical shell is LXDE and the ...
0
votes
1
answer
264
views
linux terminator: configure a command on startup and don't close terminal when the command ends
I'm using terminator con Linux, and I have configure my ~/.config/terminator/config file to start at specific folders running certain commands
I added a ; bash (also tried with ; bash && bash |...
-1
votes
1
answer
60
views
Bash readline command of scrolling terminal lines up/down
What is the Bash readline command, ie. the phrasal words command, of scrolling terminal lines up/down with shift - Page up/down
How to have all complete Bash readline commands (that are used by ...
1
vote
0
answers
60
views
With 7z-bash, how can I extract specific filetype but keep folder structure? [closed]
As it is right now you can recursively extract files via command parameters, and filter files by type. But if you add a filetype filter they will be extracted into the destination folder.
7z.exe x &...
0
votes
0
answers
184
views
Can't access remote port 81 despite netstat showing it bound
I have an apache server with multiple VirtualHosts filtered by the ServerName directive. I am now attempting to have a VirtualHost filtered based a seperate port number, but am having issues.
My ...
0
votes
1
answer
122
views
Is it possible to manipulate shell input to wrap commands?
I would like to call a function when a command is entered and modify it
for example if a user enters this command
touch foo.txt
I want to manipulate it to run
sudo -u user touch foo.txt
The reason ...
1
vote
0
answers
46
views
Why codium (vscode fork) doesn't autoclose quotes?
this is my first time using codium (vscode fork) after using atom for a while, I have installed several bash extension to enhance my shell scripting adventure, but I found that I'm unable to auto ...
1
vote
1
answer
549
views
Symbolic Link not working in sub-directory?
Newbie here. I was learning about ln command. So I created a symlink to a file foo.txt inside another directory bar.
ln -s foo.txt bar
When I try to access bar/foo.txt, I get the error "Too many ...
0
votes
0
answers
46
views
How to determine current mozc input mode in bash (command line)?
I'm using ibus-mozc and trying to determine which input method is currently set: Direct Input or Hiragana. Is it possible to determine it via command line?
Any workarounds also will be helpful
For ...
2
votes
2
answers
146
views
Replace Template String with Current Date and Time in Vim
I have a template file with the following string:
{{date}} {{time24}} Some text.
I want to replace {{date}} {{time}} with the current date and time on a keymap.
I currently have:
:nnoremap <leader&...
0
votes
0
answers
22
views
How to output disk size in GB only with no rounding error? [duplicate]
Output disk size in GB only. Giga Bytes only.
Not MB. Not Mega Bytes.
Not TB. Not Tera Bytes.
Tested thus far:
sudo blockdev --getsize64 /dev/sda
1000204886016
sudo blockdev --getsize64 /dev/sda |...
0
votes
1
answer
124
views
How to output disk size in GB only with no rounding error?
Output disk size in GB only. Giga Bytes only.
Not MB. Not Mega Bytes.
Not TB. Not Tera Bytes.
Tested thus far:
sudo blockdev --getsize64 /dev/sda
1000204886016
sudo blockdev --getsize64 /dev/sda |...
0
votes
0
answers
1k
views
Can't use ethtool | bash: ethtool: command not found
https://imgur.com/a/lM6H1v5
https://imgur.com/a/gnrydo4
I have Gigabit Ethernet on my phone and another PC(Windows), however on that one where I have Debian 12, it doesn't work. I have tried to ...
2
votes
1
answer
2k
views
"set editing-mode vi" vs "set -o vi" What is the difference?
On multiple forums I have come across adding set -o vi to my .bashrc file. Today I saw the option of adding set editing-mode vi to .inputrc.
I googled and both appear to do the same thing. Are there ...
1
vote
1
answer
272
views
Pipe in argument list of bash function
I'm using simple function to make my script more verbose.
cmd() {
echo "[#] $*" >&2
"$@"
}
When calling script with option -v all commands goes through cmd function:
...
0
votes
2
answers
423
views
awk string replacement - properly escape '&' character
I am working on one of our applications to update the docker image from using static configs for each environment to a single template using dynamic variable insertion with awk. Our Dockerfile calls a ...