Questions tagged [bash]

Bash (Bourne-Again SHell), is the default interactive user shell used in Ubuntu. Use this tag for questions specific to Bash, as opposed to generic POSIX shells.

Filter by
Sorted by
Tagged with
0 votes
0 answers
39 views

How can I run different commands in separate terminals using a shell script?

I have access to an Azure VM where I intend to run three Hyperledger Besu nodes: one boot node and two validator nodes. To automate this setup, I've created a shell script. First, I checked the ...
Shalabh Negi's user avatar
0 votes
1 answer
60 views

Backporting: Does anyone have a function to mimic bash 4 associative array?

I need to make changes in my script that uses associative array, so that the script may be used in older versions (before v4.0) of bash which did not support associative array. Can someone suggest how ...
rusty's user avatar
  • 16.3k
-1 votes
0 answers
26 views

Line 1: 410: command not found while installing NVM on Ubuntu

I'm trying to install Node Version Manager (NVM) on my Ubuntu system using the official installation script. However, when I run the following command: curl -o- https://raw.githubusercontent.com/nvm-...
Abdullahi Abdiaziz Yusuf's user avatar
0 votes
1 answer
103 views

a script to open terminal tabs and run commands

I just wanted a script to automate opening a bunch of terminals that have commands. After going through every example on the interwebs i suspect its not actually possible... myscript.sh looks like ...
user avatar
-1 votes
0 answers
137 views

Best practice to create a single panel button to process a file with awk, save it, then edit the output

In Ubuntu, what is the best practice to create a single panel button to process a somewhat large 15MB text file via awk, save that output with the same filename, and then open that file with a text ...
End Anti-Semitic Hate's user avatar
5 votes
2 answers
395 views

highlighting specific lines in different colors when starting a scipt with printf

I am using a bash script. When I launch my script, how can I highlight specific lines on the output? For example, all lines with "Enable" should be green, all lines with "Disable" ...
gabberhead's user avatar
0 votes
0 answers
25 views

dpkg; unrecoverable fatal error 'plocate'

dpkg: unrecoverable fatal error. unknown system group 'plocate' in statoverride file; the system group got removed before the override,which is most probably a packaging bug
Parameshwari's user avatar
2 votes
0 answers
65 views

Symbol gets cut off in custom bash prompt

I am using a custom bash prompt with this command that was an answer to this question: It looks like this: PS1=$'\e[1;33m\\t \e[36m\u\e[34m@\e[36m\h\e[;1m: \e[34m\w\n \[\b\e[;1;31m✘\] ${?/#0/\[\b\b\e[...
reneas's user avatar
  • 195
3 votes
2 answers
88 views

Ubuntu terminal ignoring interpreter first line

I am Windows user running WSL2 with success over the last two years. I work on a project connected to a git repository. All devs work on mac/linux so all parts of this project are targeted towards ...
Jim Halpert's user avatar
0 votes
1 answer
69 views

Trivial pursuit : bash environment variables

I know this works: FNAME="$(basename $LD_PRELOAD)" FNAME="${FNAME%.*}" Can this be expressed in a single line? These are two unsuccessful attempts, thus far: ${$(basename ...
John-L_.'s user avatar
7 votes
2 answers
978 views

Should I put functions in .bashrc, .bash_aliases or .profile

I have read this thread about where to put aliases. Now, let's suppose that my custom command is quite elaborate (takes arguments in input, is composed of several commands run one after the other, I ...
Tms91's user avatar
  • 345
0 votes
0 answers
45 views

i get this error when trying to kill pulseaudio

$ pulseaudio -k E: [pulseaudio] main.c: Failed to kill daemon: No such process Is there any other way? I tried the pavucontrol fix but it didn't work.
N.T.N's user avatar
  • 1
8 votes
1 answer
1k views

How can I properly make a bash prompt with error colors and emoji?

After solving the first issue with my custom prompt I still have another one left. When I cycle through my last used commands via the arrow-up and arrow-down keys I will sometimes have some characters ...
reneas's user avatar
  • 195
0 votes
1 answer
49 views

How to hide command output, then run another command

I have this command which may output an error, so I hide it using &>/dev/null. Now I would like to run this command, then run another command. This is what I have now: ( aaa &>/dev/null )...
Z0q's user avatar
  • 125
1 vote
1 answer
124 views

changing bash output format results in strange behaviour

I already changed my bash output format to something like this: which I am very happy with. I achieved this by adding this code to the .bashrc: set_PS1() { local RESET=$(tput sgr0 ) local ...
reneas's user avatar
  • 195
1 vote
2 answers
49 views

How to hide desktop from Ubuntu Desktop Applications UI

I found the following link for changing file types application: https://superuser.com/questions/21626/ubuntu-change-the-default-program-used-to-open-a-type-of-file Here is the command for associating ...
stackbiz's user avatar
  • 267
0 votes
0 answers
20 views

Bash script for executing linux commands on remote machines using ssh key [duplicate]

I want to run a script to get details of hardwares and user details from multiple remote machines by login using ssh private key. this is my script #!/bin/bash # Check if the user provided a file if [...
Subash's user avatar
  • 66
1 vote
1 answer
79 views

Cannot run bash script Cisco Anyconnect. "Sorry, you need user privileges to run this script." When executing as root

For work i need to install Cisco Anyconnect and i can't get it to install due to a rights issue. I have everything set up, i think correctly. I'm following this instruction. After step 8 (executing ...
CJDG's user avatar
  • 13
-1 votes
0 answers
31 views

scanning with scanimage directly with format=pdf to pdf

I have running two raspberry-instances. One of that I installed a few years ago and it is running quite fine. I have connected a scanner to that system an using it with the following line in the cli. ...
John Pam's user avatar
4 votes
3 answers
587 views

Search for a "string" or "String with Spaces" recursively that may be a file- or directory-name or a text inside a file

I would like to search for the string rstudio (and its different possible combinations mentioned below) recursively starting from /. In some locations, rstudio is a string inside another file (but ...
koustav_ch's user avatar
0 votes
0 answers
48 views

VScode not opening on ubuntu 23.10

I tried running vscode but when I write code . in bash or open vscode via the icon, VScode doesn't want to open anymore for some reason, To be more specific the vscode windows do open, but none of ...
dsdfs's user avatar
  • 1
2 votes
1 answer
113 views

Cron not running script on boot

The main idea is to make my pc run a script on boot in wich x11docker takes care of lifting a container with a youtube video. this is mi crontab -e: @reboot /usr/local/sbin/script-exo.sh script im ...
ømen's user avatar
  • 21
0 votes
0 answers
104 views

AWK issue on Bash script

I need to shortlist the logs between the particular timestamps. I can achieve it by using the below command. awk '$a>="Feb 5 10:44:*" && $a<="Feb 5 10:54*"' /var/...
Arunkumar NKL's user avatar
0 votes
1 answer
39 views

CDPATH help documentation—3

man bash says: The variable CDPATH defines the search path for the directory containing DIR. Alternative directory names in CDPATH are separated by a colon (:). A null directory name is the same as ...
Guilherme Woolley's user avatar
4 votes
1 answer
458 views

Unzip to directory of the same name

I am trying to unzip files supplied by Google Takeout and need a command to unzip all zip files in a directory to a directory of the same name as the zip file to avoid conflicts. The zip names cannot ...
Datadimension's user avatar
-1 votes
1 answer
147 views

How do I use CDPATH to cd to Documents no matter which directory I am in?

If the cd shell builtin doesn't see the target directory in the current directory, it consults CDPATH. If the target directory is absolute (begins with the root directory, /), CDPATH is not used. ...
Guilherme Woolley's user avatar
0 votes
2 answers
88 views

How can I echo double quotes around text [duplicate]

How can I get the double quotes to show for 1 second and ready? echo -e " test.sh ""1 second"" "ready""
fixit7's user avatar
  • 3,117
4 votes
2 answers
399 views

Detect that the workspace has changed

I can change my current workspace in various ways, e.g. by clicking on some switcher widget, with some key combination, with a command in a terminal. Is there a way to detect that the workspace has ...
Rodrigo's user avatar
  • 143
4 votes
2 answers
679 views

Using grep to search for line that begins with a variable whose value is a dollar sign

I found a lot of very similar problems, but not exactly this. I have a text file with the following contents (no repeats, fixed 4 characters per line): A1234 G1234 $1234 M1234 I'm trying to use grep ...
Aylox's user avatar
  • 43
0 votes
2 answers
107 views

Setting DEBIAN_FRONTEND remotely

Is there any way to set DEBIAN_FRONTEND=noninteractive when executing a script remotely via SSH? Doing so I get this error: sudo: sorry, you are not allowed to set the following environment variables: ...
Socrates's user avatar
  • 2,463
1 vote
1 answer
79 views

Ubuntu 22 shell scripts on desktop open in text editor instead of launching

I have some shell scripts (files *.sh) on my Ubuntu desktop, eg. startdoublecmd.sh or startlazarus.sh. When using Ubuntu 20, those scripts started automatically upon double clicking on them. Now I ...
tk_'s user avatar
  • 121
1 vote
1 answer
74 views

Help command documentation explanation

Running help cd gives: The variable CDPATH defines the search path for the directory containing DIR. Alternative directory names in CDPATH are separated by a colon (:). A null directory name is the ...
Guilherme Woolley's user avatar
0 votes
2 answers
82 views

How to monitor particular command or add extra functions to it?

I am attempting to implement mobile push notifications (utilizing the Docker ntfy service) for scenarios such as automatic system updates and Timeshift snapshot creation. None of these commands are ...
zawier's user avatar
  • 13
0 votes
2 answers
118 views

cron unable to run .sh script - 22.04

I am trying to run a simple script that checks the battery percentage and shows it through a notification (notify-send). The script runs correctly if ran from terminal manually: ~/path-to-script/...
overmach's user avatar
0 votes
0 answers
46 views

Byobu doesn't source /etc/profile.d scripts

I'm using Ubuntu 20.04 and byobu. One of the scripts I have in /etc/profile.d will enable bash completion for kubectl and helm for all users. It works when the user logs in but not once they run ...
rje's user avatar
  • 1
2 votes
1 answer
399 views

non-login shell sources $HOME/[.local/]bin to $PATH and I can't find why

OS: Ubuntu Desktop 22.04 I am initially logged in as user carl. I open a shell and echo $0, I get the confirmation that I am in a non-login shell. ("bash", no dash) But when I then echo $...
nocarea's user avatar
  • 23
-2 votes
1 answer
77 views

Write a Bash Command File for OpenFoam to periodically change an entry

I am trying to use an OpenFOAM case called ConstVolt_0flow where I am advised to write a bash command-file that would periodically switch the entry in ConstVolt_0flow/system/Air/fvScheme from: ...
user39178's user avatar
-2 votes
1 answer
74 views

Firefox Developer Edtion Don't show a icon in menu bar and task bar of Ubuntu. Even changing the .desktop file in /usr/share/application

I want to install a Firefox dev in bash, but I see this problem with an icon in the GNOME shell. If open the normal Firefox, in the top bar appears a grayscale icon: If you can help me I would ...
odavidcesar's user avatar
0 votes
0 answers
81 views

Avoid logging empty commands in Bash

I am using the following lines at the end of my .bashrc file to log entered bash commands to Syslog: export PROMPT_COMMAND=' RETRN_VAL=$?; if [ -f /tmp/lastoutput.tmp ]; then LAST_OUTPUT=$(cat /...
Steflan's user avatar
  • 11
0 votes
0 answers
49 views

Hi can someone provide me a solution for soft link removal?

sudo ln -s /home/user/Downloads/msms/msms.x86_64Linux2.2.6.1 /usr/local/bin/msms I created a wrong softlink in the afore mentioned script which I need to remove. Can someone please provide a suitable ...
Sambit Mandi's user avatar
0 votes
0 answers
49 views

How to autostart a jar file with swing GUI when booting Ubuntu

I'm trying to autostart a jar file with an .sh script: #!/bin/bash export DISPLAY=:0 java -jar /home/username/Desktop/jarfile.jar The jar file is a Swing GUI application. When i manually start the ...
Daniel Tscherkaschin's user avatar
0 votes
1 answer
64 views

automating keyboard key press 9 times if alt key was pressed

I want to make an automation strategy, if I pressed the Alt key with any other key, it will simulate the keyboard key press 9 times for that key. For example, I press Alt + q, it will simulate ...
Normal's user avatar
  • 123
1 vote
1 answer
115 views

What are the implications of using PROMPT_COMMAND like this?

I would like to insert the return code of the last command in reverse red color and inside brackets ([]) plus a colon (:) just before the bash (PS1) prompt. But, only if the return code is non-zero, i....
FedKad's user avatar
  • 10.4k
1 vote
2 answers
154 views

How do I set up the Bash shell to automatically line change after entering a command?

I could use that in zsh for automatically line change after entering a command, but I don't know how to do that in bash. build_prompt() {df enter code hereRETVAL=$? prompt_status ...
Seongjun Lee's user avatar
0 votes
2 answers
55 views

Retain file extension in a simple while loop (one line)

I have a simple string that will rename all jpeg files in a folder sequentially: ls -v | cat -n | while read n f; do mv -n "$f" "pic-$n.jpg"; done But I have a folder with many ...
DealTime444's user avatar
-3 votes
1 answer
82 views

Bash Script, Automated no and yes [duplicate]

I need to have a script that instructs the system to run an fsck on a drive but I only want it to run if the drive is not mounted "/dev/mmcblk0p2 /mnt/Share ext4 defaults 0 2" Basically is ...
Christopher Lock's user avatar
1 vote
1 answer
70 views

Linux directory gets random name each time mounted

I have two hard-disks each with Ubuntu, when I access the second hard-disk while being in the first one, the directory has long serial-like name, which does not allow for a quick cd alias. Which ...
ardu ros's user avatar
0 votes
0 answers
186 views

SyntaxError: Missing parentheses in call to 'print', while trying to run system

I am trying to run my system (Empire PowerShell), but it keeps giving me a syntax error. The system I used didn't support python3, so I had to install python2 which ended up working. But when I try to ...
Seul's user avatar
  • 1
0 votes
0 answers
39 views

I need to run a program, as sudo, on boot, in screen... Tried a few things but can't get it all to work

My goals are: I have "myprogram" that needs to be run in sudo I want to run it as a service at boot I want it to run inside screen so I can monitor it So I can do 1&2 just fine, but ...
Sabat's user avatar
  • 1
0 votes
0 answers
79 views

I need to run a script during first boot and want the CLI to open for possible input

Edit: I need a bit more explaining here. This is a one time only run personalization script for the computers that I have set up that I would like to run only on the first boot. After tweaking the ...
BuddyBoy's user avatar

1
2 3 4 5
224