Questions tagged [bash]

Questions specific to GNU’s Bourne Again SHell, as opposed to other Bourne/POSIX shells. For questions about Unix shells in general, use the /shell tag instead.

1,831 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
11
votes
1answer
1k views

zsh can't input to terminal when piping stdin and stdout with variable command that has tty output

System info: macOS Sierra 10.12.6 zsh 5.4.2 (x86_64-apple-darwin16.7.0) GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.3.0) Scroll to the EXAMPLES at the bottom if you just want to dig ...
10
votes
1answer
2k views

Real GNOME Wayland session

I'm trying to test a "real" wayland gnome session. I know that not all applications can run on Wayland natively (for this we have XWayland) but at least I would like to have GTK+ applications to do so....
7
votes
0answers
514 views

Monitor exit code in tmux

Is there a way to update tmux window attributes based on command exit status? Similar to activity monitoring, I would like the title to change color when a command exits, say, green for success and ...
6
votes
1answer
471 views

autocomplete filenames with underscores

What do I need to add to my ~/.bashrc so that if, for example, there is a file named name_separated_by_under_score, I can press n-s-b-u-s and then [TAB] and the shell will auto-complete the file name? ...
5
votes
0answers
82 views

Pasting into terminal including comments issue

This is somehow a follow-up to my last question: Pasting multiple commands into terminal stops at user input Pasting the following to the terminal works as expected: ( echo test1 # some comment echo ...
5
votes
1answer
637 views

Sending SIGINT to process groups sometimes gets ignored

I start a process group from bash. Then I send SIGINT to the entire process group. Sometimes the SIGINT kills the processes, sometimes does not. Why does SIGINT sometimes gets ignored ? I see ...
5
votes
1answer
727 views

Logging the output of remote commands on multiple ssh servers without delay

I've written a simple bash script that ssh's into 3 hosts (2 remote, 1 my own for testing) and runs a long running gui program that outputs text to the terminal that I'd like to log. #!/bin/bash ssh ...
5
votes
0answers
3k views

“-bash: /root/.bashrc: Permission denied” when logging in

I have this server running Centos 7. Every time I log in (remotely or locally) with every user I get an error. If I log in as root I get -bash: /root/.bashrc: Permission denied If I log in as a ...
5
votes
1answer
520 views

Assign both menu-complete and dynamic-complete-history to TAB

Is there a way for me to assign both menu-complete and dynamic-complete-history to Tab (or one to Tab and the other to Tab-Tab) in .inputrc? I'm thinking there might be a way to setup a function and ...
5
votes
2answers
1k views

When using expect: SSHFS Transport endpoint is not connected

When I run my SSHFS connection script from bash, everything works perfectly. However, when I run the same script using the expect utility, I get the following error when I try to access the folder ...
4
votes
0answers
62 views

What are exactly shells levels?

My understanding of shell levels and sub-shell was that: Sub-shells are forks (but not execs) of the shell process created by ( ... ) constructs. $SHLVL counts shell execs. $BASH_SUBSHELL counts sub-...
4
votes
1answer
151 views

Adding “sudo” commands to the bash history of the *target* user

Something that's bothered me for many years is that if I want to search my shell history for commands which were run as root, I have to check two different locations: I have to check /root/....
4
votes
0answers
42 views

Bash completion own compgen prefix

I have a simple bash completion script that essentially invokes my (non-bash) program and set its output to COMREPLY, i.e. COMPREPLY=( $(my-program -- "${COMP_WORDS[@]}") ) Some of the options ...
4
votes
0answers
123 views

How can I properly use an American flag emoji in my bash prompt?

I want to use an American flag emoji in my bash prompt (i.e. PS1 environment variable). However, the American flag emoji causes the terminal cursor to offset an extra character to the right. πŸ‡ΊπŸ‡Έ is ...
4
votes
0answers
307 views

how to avoid writing failed bash commands to bash_history

I'm looking for a nuanced history behavior I haven't seen anywhere. During a terminal session, I want every command, regardless of exit status, to be appended to the in-memory history. Upon exiting ...
4
votes
0answers
664 views

How to bind to ctrl+x in bash?

I appear to be using GNU bash, version 4.4.12, though it's possible my organization has modified it from HEAD. I'm trying to bind ctrl+x: $ bind -x '"\C-t": "echo testing"' <I press ctrl+t> ...
4
votes
1answer
219 views

is it possible to colors the prompt for (reverse-i-search) context menu?

I am using fedora 25 but I think this is a general behavior on unix system. When I ctrl+r in a command-line environment I can start to type in and anything I type will get to be matched backward in ...
4
votes
2answers
291 views

bash/cygwin broken after installing rtool?

Usually I can solve problems on my own (and Google). But recently I am baffled by this strange hiccup. Background: I use a chain of scripts for file-processing (in Windows, under Cygwin. Scripts ...
4
votes
0answers
343 views

Replacing a running binary on read-only file system

I have a simple updater bash script, which replaces files by removing the incident old files and copying new files from an archive to the running embedded target root file system. This way, the script ...
4
votes
0answers
730 views

Understanding inotifywait, pipes and buffers

I want to monitor every file change in a directory with inotifywait. inotifywait shall write to a FIFO buffer, which then can be read, leisurely. While experimenting with relatively huge amounts of ...
4
votes
1answer
1k views

TOR hidden service not always accessible through cURL. Takes multiple tries

When I try to access a hidden service on TOR using cURL, for some reason I'm not getting access to the site 100% of the time. Many times it returns "curl: (7) Can't complete SOCKS5 connection to 0.0.0....
4
votes
0answers
306 views

Bash command not found due to stray garbage characters

What is the cause of this behavior? $ cd ../ $ bash: $'\210\210cd': command not found This happens sometimes (rarely) when I enter a command, there is no visible character preceding the cd, still it ...
4
votes
1answer
2k views

Automating sshfs not working

I want to mount a remote directory and I want to automate this. So I write below script which not working properly. #!/usr/bin/expect -f spawn sshfs vedams@192.168.5.109:/home/user /mnt/remote expect ...
4
votes
0answers
1k views

Powerline bash prompt not colorized in tmux

The bash/zsh commandline prompt is not displaying colors in tmux, even though I managed to get the powerline itself working (with colors). The prompt works fine in pure bash/zsh. I am getting the ...
4
votes
1answer
70 views

git report moved lines

I want to track the number of additions and deletions that exclude moved lines. So if a commit has 10 additions, 5 deletions, and 3 moved lines, then I have 7 additions, 2 deletions excluding moved ...
4
votes
1answer
1k views

KSH styling text based menu using STDERR

Is it possible to format the STDERR in order to have a better looking menu using the select command? I have a simple select select oChoice in $(<tempMenu.menu) ; do case "$oChoice" in ...
4
votes
2answers
1k views

Bash shell launched by forkpty() spawns child processes that ignore SIGINT. Why and how do I ensure SIGINT is not ignored?

I have a C program that uses forkpty to execute a bash shell. I'm finding that the programs launched by this shell are launched with SIGINT ignored, so when I send a Ctrl-C to the shell they never ...
3
votes
0answers
45 views

Why does CTRL-C work in one user account but not another?

I have a bash script which is supposed to run a command every X seconds, until the operator interrupts it. Like this: test.sh #!/bin/bash while true; do echo Doing a thing... sleep 3 & ...
3
votes
1answer
46 views

Create folders with unique names of filenames

I am trying to create folders from unique filenames. Here are the files: T001 └── 20000101 β”œβ”€β”€ 6_3D-MP-RAGE_97.dcm β”œβ”€β”€ 6_3D-MP-RAGE_98.dcm β”œβ”€β”€ 5_133_VOLUMES_99027.dcm β”œβ”€β”€ ...
3
votes
1answer
127 views

Get and set the script arguments from within a function in bash

Context: I have an old bash script with a big section parsing its arguments. It happens now that I need to call this section twice, so I plan to move it to a function to avoid code duplication. ...
3
votes
1answer
71 views

How to escape linux character over ssh

I am trying to figure out exactly what is sent to an SSH host when I press CTL-C in either putty or open ssh. All I am trying to do is send control codes pragmatically that are equivalent to when a ...
3
votes
0answers
47 views

Colorize the PS4 prompt?

With the option set -x, each command is echoed to STDERR before execution, prefixed by the expanded $PS4, with the first character being repeated according to the call stack depth. I want the output ...
3
votes
1answer
119 views

Nested command substitution does not stop a script on a failure even if -e and shopt -s inherit_errexit are set

Suppose you have a following script sandbox.sh. (This looks similar to Command substitution inside a function does not stop the script on a failure even if -e is set, but I believe a bit different ...
3
votes
1answer
138 views

Why can't I use tab for autocompletion in neovim over SSH?

When used locally on arch I can easily use tab for auto completion in vim when e.g. filling in a path with deoplete. If I SSH to this computer from my laptop then tab still works for completion. But ...
3
votes
0answers
47 views

How to avoid bash from accepting non-printable characters at the prompt?

I recently ran a command at my shell: # yum whatprovides xdotool Error: No Matches found However, my package manager actually has this package: # yum whatprovides xdotool xdotool-1:3.20150503.1-7....
3
votes
0answers
84 views

What does it mean if a process has an O or an I at the start of the line?

After running ps, I noticed that a couple of the processes had an O at the start of the line. In all my years, I've never seen this. I thought that the meaning of the indicator might be common ...
3
votes
0answers
45 views

Why does the touch command works in one directory and not in the other?

On the same mount, the touch command sometimes doesn't work Using different directories on the same mount, the touch command gives different results **bob@syno ~ % ll -d /volume1/media ; ll -d /...
3
votes
1answer
258 views

XFCE - Blank text in terminal

I've just performed a fresh install of Arch Linux on my laptop (ThinkPad A485, though that's probably not relevant here), and installed XFCE4. Everything seems to be working with the exception of one ...
3
votes
0answers
103 views

Legitimate reasons for a program to intercept, internally handle and ignore SIGINT signal

We know that - aside from SIGKILL and SIGSTOP - a program can intercept IPC signals, and run its internal handler circumventing the operation of the default handler. I can think of at least one very ...
3
votes
0answers
58 views

Git - prune every whitespace-separated word originally introduced by specific author in project's history

We have a project under git revision control with only a single branch. We need to remove every new whitespace-separated word that was introduced for the first ever time in a given file by a specific ...
3
votes
0answers
390 views

Bash 4.4 change color vi mode

I am using +~ $ bash --version GNU bash, version 4.4.0(1)-release (x86_64-unknown-linux-gnu) Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://...
3
votes
1answer
764 views

How to 'hash -r' and refresh all shells?

This is related to What is the purpose of the hash command? After installing a program I am looking for a way to tell all open shells to update their cache. I often have 6 to 8 of them open and I don'...
3
votes
1answer
734 views

Trap does not catch SIGTERM in child script

I have two scripts. First one is basically wrapper that calls subscript and sets timeout. #!/bin/bash # wrapper_script timeout --signal=SIGTERM 50 main_script.sh And if execution of main_script.sh ...
3
votes
1answer
632 views

Script or Program to discover hosts on network

Explanation: I need a script or program to discover devices on my network. I was thinking maybe doing the scan with nmap and I need to display just the name of device, what it is, and also the ip ...
3
votes
0answers
639 views

How to set the default color of output / things typed in Bash

When I am typing or viewing text on my terminal, the color is white. Any command after I type my prompt is white, and the default output (stdout) is white. I looked and my terminal emulator does not ...
3
votes
1answer
256 views

Signal not received by script run using sh -c

I have a script which sleeps for 3 minutes before running a time consuming command. I want the script to exit if it receives SIGINT only while it is sleeping, and not when it is executing the long ...
3
votes
0answers
334 views

Control characters in a terminal with an active foreground process

Say I have a process running in a terminal in the foreground. While it is active I can type commands, hit return, and those will be executed once the process is done. Now say furthermore I would like ...
3
votes
1answer
70 views

Faster auto-completion for kanjis files/folders, without having to switch IME

I have a project with many Japanese kanji/kana folder and file names, like this: ζζ‘ˆζ›Έ/ フォルダ/ ε·₯ζ•°.sh θ¨­θ¨ˆζ›Έ.sh It takes so much time to change directories or open a file: Type the first part of the ...
3
votes
2answers
2k views

How to display commands executed via ssh and their user's IP?

I asked a question before, but I didn't get a satisfying answer in : How can I display ssh commands executed from another machine? so I'll ask this time precisely. How to display commands and their ...
3
votes
1answer
142 views

How to count subprocesses that reached certain state

I have a bash script that launches >20 subprocesses (functions launched with & in background) and want to include a progress indicator that tells the user how many of those subprocesses are ...

1
2 3 4 5
…
37