Skip to main content

Questions tagged [bash]

Bash is a free shell for Unix-like operating systems from the GNU Project.

Filter by
Sorted by
Tagged with
0 votes
1 answer
76 views

Why do string variables in a bash script behave differently when echo'ed than they do when passed to an executable?

I have the following script: #!/bin/bash KID3=$(command -v kid3-cli) ARG1="-c 'get'" file="'1-01 - Johann Strauss - __Waldmeister___ Ouverture.flac'" echo Command: echo "$...
Frank van Wensveen's user avatar
0 votes
0 answers
32 views

Unknown terminal: "/tmpERM"

On my Linux headless distro, i have a recurring error where when running some commands ("clear", "nvim", etc.), instead of the expected behaviour of running the command i get an ...
lo9ud's user avatar
  • 1
0 votes
0 answers
30 views

Is there any way to create a new window terminal (pseudo-terminal) using a command without setting env $DISPLAY?

I am currently building an open-source utility (plugin), which requires a new terminal window (pseudo-terminal) to become more effective whenever it gets executed. I was using gnome-terminal to ...
zenitsu's user avatar
1 vote
0 answers
21 views

How to calculate GUI used memory widget value?

OS: Kubuntu 22.04.4 LTS x86_64 to display above: neofetch --stdout |grep 'OS:' GUI = Graphical User Interface GUI used memory = see widget image below. . 2nd method to display used memeory = 2211 MB =...
joseph22's user avatar
  • 367
0 votes
2 answers
206 views

How to run command containing string variable from string variable?

I'm trying to run command containing string variable from string variable: $ X="bash -c 'echo OK'" ; $X OK': -c: line 1: unexpected EOF while looking for matching `'' Why doesn't it work? ...
pmor's user avatar
  • 346
0 votes
1 answer
58 views

Bash completions with more than one word

My command is thermostat.sh override off I can get override to complete but not the subsequent off Here is my script #/usr/bin/env bash _thermostat-completions() { if [ "${#COMP_WORDS[@]}...
Richard Barraclough's user avatar
1 vote
0 answers
95 views

How to automatically reconnect to WiFi when 'limited' connectivity occurs?

I'm experiencing an issue with my school's WiFi where it stops working every 5 minutes or so. When this happens, nmcli monitor shows "Connectivity is now 'limited'". I have this short script ...
Alexandre Ramos's user avatar
2 votes
1 answer
108 views

tmux doesn't instantly update pane's title

I'd like to have tmux "instantly" update the pane's title to match what is currently being executed in the terminal. For an instance: If the pane contains the shell then its title should be ...
pic810's user avatar
  • 21
1 vote
2 answers
146 views

FFMpeg: How to get the real return value in bash

I've always used ffmpeg via a cmd-script and I always could check the %ERRORLEVEL% which was always '0' on success or '!0' if an error occured. I'm trying to recode my cmd-scripts in bash (using msys2 ...
lhksoft's user avatar
  • 13
0 votes
1 answer
69 views

I'm getting on gitbash a warning WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! for github

When I try to clone a git repository in gitbash on Windows I get following error: $ ssh -T [email protected] @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST ...
Asterios Raptis's user avatar
0 votes
0 answers
41 views

How to match PDF okular colors with Terminal colors?

OS: Kubuntu 22.04.4 LTS x86_64 okular 21.12.3 konsole 21.12.3 to display above: neofetch --stdout |grep 'OS:' okular -version konsole -version outputs: ok match color Blue in Terminal with ...
joseph22's user avatar
  • 367
1 vote
0 answers
66 views

How to let root use sudoedit as if it was a user?

I'm writing a wrapper for myself around vim that detects when the user's trying to edit a file that doesn't belong to them, and suggests sudoedit or visudo instead. I want to use sudoedit rather than ...
aaaalz's user avatar
  • 11
1 vote
1 answer
243 views

TO close Tmux along with terminal (if terminal is closed)

I have configured my Tmux to open with i open terminal by modifying the .zshrc file. [[ -z "$TMUX" ]] && tmux -u It worked fine, now I want to close the tmux session when I close ...
shohel hossain's user avatar
0 votes
1 answer
83 views

Determining task length for progress bar bash

I am trying to find a way how long a progress will take so i do not hard code a set time length. I am trying to do this without adding any new libraries. the pv command seems pretty popular but my ...
Abbatrombone's user avatar
0 votes
3 answers
39 views

Why doesn't `bash` work with piped output, when the output is as expected?

I'm running the following command to alias an entire folder of scripts: ls | grep '\.sh$' | sed 's/\.sh$//' | awk '{print "alias "$1"=\"./"$0".sh\""}' | xargs -...
Maxime Franchot's user avatar
0 votes
1 answer
655 views

How can I reset my MySQL root password in MySQL 8.0.36 on Red Hat 8 if ‘mysqld_safe’ is gone?

For years I have been using mysqld_safe (like this) with --skip-grant-tables so I can safely reset my MySQL root password: sudo mysqld_safe --skip-grant-tables & But recently, while attempting ...
Giacomo1968's user avatar
0 votes
0 answers
113 views

Can you write a script that contains both bash (or sh) and powershell (or cmd, bat) so the same file can be executed on Win and *nix?

I have a script that needs to run on Windows, Linux and MacOS. I know Windows determines how to run a script by using the file extension, where *nix will use the #!. I'm hoping there is enough syntax ...
David Alsh's user avatar
0 votes
0 answers
58 views

Failure to use `/dev/pty` for one outside msys2 `bash` when calling it in `vim` installed inherently by git-bash

Env: Windows 11 pro. I want to call msys2 bash in git-bash's vim where both shares the same version of vim and bash (although this context seems to be weird). I asked one origin question in Vi/Vim SE ...
An5Drama's user avatar
  • 151
3 votes
1 answer
294 views

How to remove all subtitle channels except the first English one with FFmpeg?

I'm not very well versed on FFmpeg, and I've tried to do this many times myself, but I couldn't even figure out the syntax.. So I'm going to ask outwards to people much smarter than myself. I wish to ...
Novum Gain's user avatar
1 vote
0 answers
56 views

How to detox filenames in a bash script with no errors posted?

OS: Kubuntu 22.04.4 LTS x86_64 detox 1.4.5 To display above: neofetch --stdout |grep 'OS:' detox -V Here is a toxic filename, starts with s1: s1 Ä Ö Ü - ä ö ü Science & < > " 1 \ 2 ⁄ 3 ...
joseph22's user avatar
  • 367
0 votes
0 answers
82 views

How to launch another blank terminal in Kali Linux?

When I launch another terminal in Kali Linux with Cmd+Shift+T, I can see Shell No. 2 tab created. However, it is just a copy of Shell No. 1 and all the commands I ran on Shell No. 1 are visible on ...
kerblue's user avatar
2 votes
1 answer
117 views

Execute self-extracting bash script (with binary data appended) w/o saving it first

I have a self-extracting bash script (binary data appended to the end) like this: #!/bin/bash export TMPDIR=$(mktemp -d) ARCHIVE_START_LINE=$(...) # <omitted> # extracting data archive into a ...
Edward Ruchevits's user avatar
1 vote
1 answer
34 views

Moving directories that names end in - number matching a list.txt file

Graphic of Folder Structure : I am very new to advanced shell commands and scripting. I have fundamental terminal knowledge but have never attempted to create an automation like this before. A pure ...
Roco Gman's user avatar
-1 votes
1 answer
74 views

Search and replace doesn't work with sed busybox. getting sed: unmatched '/' error

I am trying to search a particular string and replace all occurrences within a file. sed -i -e "s/$search_string/$replace_string/g" $filePath I keep getting sed: unmatched '/'error on ...
aelor's user avatar
  • 99
1 vote
2 answers
114 views

How to detect if “/dev/mapper/dev0” exists in Bash?

I'm trying to make a decryption software for my NAS, so that it automatically mounts all drives and decrypts them. But, I need to know if the sudo cryptsetup luksOpen /dev/blahblahblah dev0 exists ...
Novum Gain's user avatar
0 votes
1 answer
86 views

Changed color settings of ble.sh bash terminal are not applied

I installed the ble.sh from this git repository https://github.com/akinomyoga/ble.sh.git, but i want to customize the color settings with ble-face commands. What happens is that, I changed the color ...
Vitor Martins's user avatar
10 votes
4 answers
2k views

Why does assigning a variable with command substitution, and then echoing that variable, always fail?

Why does the following not work in Bash? # Ensure TEST is unset export TEST='' echo "Hello world!" > test.txt && TEST="$(cat test.txt)" echo "$TEST" It always ...
Rob's user avatar
  • 103
1 vote
1 answer
97 views

Keep command line visible while scrolling

Unsure what the best place to tackle this would be .bashrc? Using different shell? Some fancy terminal emulator? Basically, I just want to keep seeing the command line / the last line of the terminal ...
sonofevil's user avatar
  • 127
0 votes
0 answers
29 views

How to read from a kwallet map per kwalletcli?

I try to use kwalletcli to access a password in a bash script. I know how to access ordinary passwords. But in the kwalletmanager GUI tool there is another kind of entries which is called Maps. Look ...
stollr's user avatar
  • 202
0 votes
2 answers
226 views

Remove all files with name starting with single quote

I need to delete all files with these names (the quotes are part of the name): 'index.html?some-query-string' I tried with: rm \'index.html?*\' I get this error: rm: cannot remove ''\''index.html?*'...
Giacomo M's user avatar
  • 143
0 votes
0 answers
201 views

how to use curl for single sign-on website or page

I've already written a shell script but it's not working. I'm getting an empty response whereas it should first return a token and also it should login then register the API. That's the task which my ...
DevOPs's user avatar
  • 1
0 votes
1 answer
303 views

How do I make a command line always show in front of another app

let's say I only have one monitor and I open an IDE and a powershell window. I need to type words in the IDE's current tab while watching the conent of the command line. The problem I have is, ...
user22155685's user avatar
0 votes
1 answer
58 views

How to simply cleanup a filename?

OS: Kubuntu 22.04.4 LTS x86_64 to display above: neofetch --stdout |grep 'OS:' . How to simply cleanup a filename, not file contents? by removing from a filename: \n newlines \t tabs non printable ...
joseph22's user avatar
  • 367
0 votes
0 answers
102 views

Split pdf into separate files based on keywords

I work in an organization with a Purchasing dept. that processes a lot of POs. When they "print" a PO job to pdf, the resulting pdf can have pages for one or more Purchase Orders. For ...
reebo's user avatar
  • 1
1 vote
0 answers
89 views

MPV to play videos with a geometry

I have YOCTO build and I have integrated the mpv to the image. I need to test something so, I wrote a script that could play videos with a certain width and height and position on the screen but mpv ...
thehilmisu's user avatar
0 votes
2 answers
233 views

Bash provide comma-separated list in multiple lines

I have a bash script that is suppose to run another program called file-selector. #!/bin/bash ... ./file-selector -exclude="a/b/c/d/e/f1,a/b/c/d/e/f2,a/b/c/d/e/f3,a/b/c/d/e/f4,a/b/c/d/e/f5,a/b/c/...
Subzero123's user avatar
0 votes
0 answers
67 views

docker compose down service with label

I'm trying to figure out how to programmatically compose down several services with a label. Currently I'm just using docker container stop as such: docker container stop -t 60 $(docker ps -q -f "...
Modem7's user avatar
  • 1
1 vote
1 answer
59 views

merge numbered files from different directories into same directory in correct order

I have some directories named FOO and BAR and etc. that have files in form FOO/ 1.png ... 18.png BAR/ 1.jpg ... 12.jpg ... and I would like them to be all copied into the DESTINATION directory ...
user3446323672's user avatar
0 votes
1 answer
236 views

Broken pipe, write error: An epidemic of unnecessary output

In the last few months, a problem has been spreading across my systems. That of broken pipe errors: # Solution: # silenced by replacing /bin/bzip2 -> bzip2-reference # to /bin/...
Hincor's user avatar
  • 1
1 vote
1 answer
77 views

What's a good way to encode a file name for caching a video thumbnail?

I'm writing a previewer script for lf using chafa to display preview images as sixels. I'm writing the part of the script for previewing videos, and decided to just display the first frame of the ...
revsuine's user avatar
0 votes
2 answers
46 views

An incorrect path is displayed in my custom command line prompt in bash

I would like to display the current and parent directories in my Linux command prompt. For example, if the current directory is /home/user/proj/src, I'd like the prompt to display proj/src. I found ...
Epsilon's user avatar
  • 103
0 votes
1 answer
89 views

Arch linux: How to exclude files from subfolder while using rsync for copying

I wanted to make a copy of files from one directory (folder "test2") to another directory (folder "Destination") while using rsync in linux console. The only problem? I want to ...
Minja Culic's user avatar
2 votes
0 answers
102 views

Why my terminal throws control characters while using arrows in mysql-client?

I have a situation with remote servers (all Debians) where I get control chars into mysql-client command line when I try to search in history (CTR+R) and try to make the first move: mysql> update ...
wk.'s user avatar
  • 188
0 votes
0 answers
28 views

Set terminal color without having bash history look wrong? [duplicate]

A site suggested I wrote the below to set the color of my terminal in `~/.bashrc export PS1=`printf "\033[32m$ \033[39m"` If I log in through ssh, press up, home, up text will be garbled. ...
Andrew Spar's user avatar
0 votes
2 answers
488 views

How to output a bright Green check mark?

OS: Kubuntu 22.04.4 LTS x86_64 to display above: neofetch --stdout |grep 'OS:' Terminal or bash script: printf '\u274c\n' # works fine. Bright red X. ❌ printf '\u2714\n' # outputs a check mark, ...
joseph22's user avatar
  • 367
0 votes
1 answer
78 views

The last command output in linux for reboot is not giving the uptime instead it says still running twice

[root@localhost test]# last -x reboot -s -30days reboot system boot 5.14.0-325.el9.x Sun Mar 10 10:51 still running reboot system boot 5.14.0-325.el9.x Tue Mar 5 03:05 still running In the ...
AshKash's user avatar
1 vote
0 answers
29 views

How to make a script to launch different scripts in different workspaces in linux?

I have limited access to a linux machine, meaning I cannot install any external tools. I want to make a script to open terminals with ssh at different workspaces. However, I found that one way to move ...
Yi Qiang Ji's user avatar
2 votes
1 answer
51 views

How can I use the last changed file as an argument in linux?

I'm thinking of using the last changed file as an argument to commands like ls, echo, or cat, is there a simple and efficient way? this question arose when I was faced with analyzing the latest log ...
Ilgar's user avatar
  • 21
0 votes
1 answer
207 views

How to tell if SIGWINCH has been activated in bash

I am trying to get it to were if the window size changes in the terminal it redraws a box. I am unsure of how to catch this signal, the documentation I was able to find online was not particularly ...
Abbatrombone's user avatar
10 votes
4 answers
3k views

How to achieve side by side output in Bash?

I have a script, let's say it's this (obviously, my real one is much more complicated): echo A echo a echo B echo b echo C echo c echo D echo d Is there an easy way to have the lines side by side? A ...
Andrew Spar's user avatar