New answers tagged

1 vote

PowerShell-like history auto suggestion for Bash

I think using fish might help you with this. sudo apt install fish then open terminal right click on it and go to preferences -> Command -> Enable Run a custom command instead of shell and ...
user64bit's user avatar
2 votes
Accepted

Auto-completion puts back-slash before $ mark, how can I disable it? (ubuntu 22.04)

This behavior is controlled by the direxpand shell option: direxpand If set, Bash replaces directory names with the results of word expansion when performing filename completion. This changes the ...
steeldriver's user avatar
2 votes

How to keep ssh command running when python script called by ssh command exits with an error?

As mentioned in my comment, the command passed to the SSH is bash -e path/to/script, which terminates the script on any non zero exit status. This choice of option was necessary to catch a Ctrl+C ...
Legh's user avatar
  • 41
2 votes

PowerShell-like history auto suggestion for Bash

As also suggested by @muru in a comment, there is the ble.sh ―Bash Line Editor― that can do what you want. Before installing it, you have to install its dependencies (if not already installed): git, ...
BeastOfCaerbannog's user avatar
1 vote

Timer program that plays 4 sounds one after another for 30 seconds each

A few years ago I posted a bash script here in Ask Ubuntu that addresses the multiple-timer issue: Run set of alarms consecutively However, it allows only one custom sound file used on all the ...
WinEunuuchs2Unix's user avatar
0 votes

How to print text in the terminal as if it's being typed?

With awk: echo "Hello world" |\ awk '{for(i=1;i<=length;i++){ printf "%c",substr($0,i,1); system("sleep 0.25");}; print ""}' Source: https://unix....
Cyrus's user avatar
  • 5,444
0 votes

How to print text in the terminal as if it's being typed?

This is how I simulate typing code for my YouTube channel @SortedSand The "calc.cpp" file is a C++ source code file. clear && cat calc.cpp | pv -qL 5
Sorted Sand's user avatar
6 votes
Accepted

Timer program that plays 4 sounds one after another for 30 seconds each

(I will use it as a reminder to brush each quadrant of my teeth when using a electric toothbrush.) I have to say, this is one of the strangest reasons I have ever heard (electric toothbrushes have ...
Raffa's user avatar
  • 27.8k
4 votes

PowerShell-like history auto suggestion for Bash

There is a replacement for the built-in Ctrl + R called hstr. It allows you to search command history, matching all search tokens at the same time (among other things), and cycle through the results ...
stumblebee's user avatar
  • 3,332
0 votes

Git (Credential Manager) not found after deleting /home/.dotnet

.NET had changed my Git configuration to use itself as the credential manager, which then broke when I deleted it. To fix, I ran the first two commands as per this issue $ git config --global '...
Victor Liu's user avatar
0 votes

"Syntax error: Unterminated quoted string"

In Bash, if you want to escape a single quote, you can't just add a backslash to it... Wrong code: echo 'This is not how it\'s done'. Correct code: echo 'This is how it'\''s done'. See SC1003 – ...
James Bond's user avatar
1 vote

What type of value do instructions return?

It returns an integer exit status - just as a C entry point (main function) should: $ ls -d ~testuser /home/testuser $ echo $? 0 $ ls -d ~nosuchuser ls: cannot access '~nosuchuser': No such file or ...
steeldriver's user avatar
0 votes

Should we put file names in Bash in Quotes or Double quotes? What is the standard?

Both will work, although slightly differently. The biggest difference is that between single quotes, most shell expansions (wildcards, variables, command substitution, etc) do not take place, so if ...
dolt's user avatar
  • 325
5 votes

Bash file while loop isnt running well

Although syntactically valid, the expression i=$i+1 is a string assignment, so that the second time through the loop you are comparing literal string 0+1 to an integer $numberOfLoops To get arithmetic ...
steeldriver's user avatar
4 votes
Accepted

Bash file while loop isnt running well

This is not numeric addition: i=$i+1 It's string concatenation. If $i is 0, after the assignment it's 0+1. This is numeric addition in bash: ((i=i+1)) or shorter ((++i))
choroba's user avatar
  • 9,388
1 vote

Bash: Define a function in bashrc that can be used by any scripts globally

Alternatively, you can 'run' your script file by sourcing it. Let's say you have defined your custom script with functions in ./myScript. Then in the beginning of each script where you want to use ...
jo_'s user avatar
  • 109
1 vote

Test -s is failing

Running the line in your script - ROOTNAME="/mnt/backup/"\`date +"%Y%m%d"\` ; echo $ROOTNAME results in: +%Y%m%d`: command not found Perhaps this would be a better way to define ...
stumblebee's user avatar
  • 3,332
10 votes

Should we put file names in Bash in Quotes or Double quotes? What is the standard?

One thing to note about variable assignments is that they are a bit of a special case in shell syntax. From the Bash documentation, in 3.7.1 Simple Command Expansion: The text after the ‘=’ in each ...
muru's user avatar
  • 195k
5 votes

Should we put file names in Bash in Quotes or Double quotes? What is the standard?

No quotes example: filePath=Documents Folder 2 echo "$filePath" This will echo Documents. Everything after the first space will be lost. You need the quotes in order to retain the spaces. ...
Stormlord's user avatar
  • 6,147
0 votes

How to remove special 'M-BM-' character with sed

You can also paste the special unicode char in your sed command, like this: sed 's/ / /g'
Teddy C's user avatar
  • 101
4 votes
Accepted

Should we put file names in Bash in Quotes or Double quotes? What is the standard?

There is no "standard" according to the Bash Reference Manual. Variables (Shell parameters): A variable may be assigned to by a statement of the form name=[value] Quoting: Quoting is used ...
Artur Meinild's user avatar
0 votes

Execute sh script from *.desktop file?

Make a file called testicon.desktop and place it on the desktop $ more testicon.desktop [Desktop Entry] Version=1.0 Type=Application Terminal=true Icon=/home/robin/Desktop/testicon.png Name=TestIcon ...
Robin's user avatar
  • 139
0 votes

How to Disable Daily Message in Ubuntu 22.04.3 LTS [Message of the Day (MOTD)]

To disable the daily message that appears in Ubuntu 22.04.3 LTS, follow these steps: Open the terminal. Use the following command to create the .hushlogin file in your home directory: touch ~/....
Dhananjay Porwal's user avatar
10 votes
Accepted

Bash alias for removing docker images does not use force flag

First, you should probably follow the syntax in the original documentation, which is docker rmi -f <images>. Also, when defining an alias, you should use single quotes to evaluate the expression ...
Artur Meinild's user avatar
0 votes

tmux status bar is breaking

There's a troubleshooting section in the Readme that starts just below the install directions. More specifically it includes, "Status line is broken and/or gets duplicated at the bottom of the ...
l3l_aze's user avatar
  • 237
1 vote

Want to execute a script irrespective of the directory where this script is present or html file is present

You're setting $HTML_PATH, but you're never using it. Try: python -m http.server --directory "$(dirname "$HTML_PATH")" $PORT Check here
pLumo's user avatar
  • 26.6k
19 votes
Accepted

A binary file exists but shell says no such file

This confusing error, no file found, is what you get if you try to run a binary compiled for a different architecture. In your case, you are running on an AArch64 system, on an ARM chip. However, your ...
terdon's user avatar
  • 99.4k
0 votes

`http_proxy` not showing up with `printenv` on WSL

The issue you're having as due to "bash not picking up /etc/environment" in WSL. I stumbled upon it and it's nasty. What's more nasty is that it's a 7 years old issue, as of writing, still ...
Angelos Pikoulas's user avatar
0 votes

Sudo doesn't work, pkexec visudo neither

It looks like you have done a sudo chown -R 1000 /. This has irrevocably trashed your system. Do what you can to save your data and reinstall. It's ls /etc/sudoers /etc/sudoers.d
waltinator's user avatar
  • 35.8k
0 votes

How to start an app from a bash script without opening/showing terminal window?

if I understood your question well you want to run a script with out the need to open the terminal right To start an app from a bash script without opening a terminal window, you can use the & ...
coder-x's user avatar
3 votes
Accepted

PerformanceTest on Ubuntu

see: passmark.com/support/pt_linux_faq.php "Permission denied when trying to run from command line?": You need to enable execution permission for the file. Run "sudo chmod +x ./...
Luuk's user avatar
  • 276
0 votes

How to pass an array as function argument?

No you cannot pass arguments to a function in Bash. Arrays are not really first class objects and all of the solutions above just end up being workarounds with lots of leaky abstractions. The key ...
oligofren's user avatar
  • 630

Top 50 recent answers are included