Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

3
votes
1answer
49 views

Logging bash output to a file

I'm trying to build vlc which is rather complicated and dependent on having the right packages installed, and keeps choking on errors. To trace all my steps I wish to output what I'm doing to a ...
9
votes
1answer
241 views

Why Ctrl+m and Ctrl+q wasn't used in bash shortcuts?

Recently I've been viewed through bash shortcuts key, and trying to find an appropriate one for my tmux activate key. And I find an interesting fact that ctrl + m and ctrl + q are not used in bash ...
3
votes
2answers
37 views

Parameter expansion in variable assigned with a wildcard

I have two files in my current folder (MA502) whose names are - MA502_TAAGGCGA-TCGCAGG_L001_R1_001.at.fastq MA502_TAAGGCGA-TCGCAGG_L001_R2_001.at.fastq I have many such folders - ex MA503, MA504 ...
10
votes
2answers
386 views

Can bash write to its own input stream?

Is it possible in an interactive bash shell to enter a command that outputs some text so that it appears at the next command prompt, as if the user had typed in that text at that prompt ? I want to ...
1
vote
0answers
20 views

-devilspie doesn't play nice with spawning new terminals

I'm trying to configure devilspie so that on detection of opening a certain directory it runs a script to mount that directory over a network. I don't think the script itself is too important but ...
1
vote
3answers
32 views

put split command and arguments on a variable in bash script

I have a script that repeat many times the same grep command, so i want to put that string on a variable making the script more readable for me, cutting the line length. This is the line (that repeat ...
0
votes
2answers
53 views

breaking out of command loop but exit code not the reason?

I run the following: echo "while emacs;do echo $?;done;echo Exit code: $?;" | bash If I exit emacs through the menu or the close button, it prints exit code 0 and restarts. If I exit emacs through ...
-1
votes
1answer
37 views

Matching regular expression with delimited string in unix

Can someone help me in matching the below delimited regular expression in bash script: number|my_name|number I have tried the below but could not get it through end: sed -e 's/[^[[digit]]*//g
0
votes
1answer
18 views

Import list of IPs into DEVICE=eth0:X

I have a list of IPs I would like to import into my Linux VPS. They are not an IP range. How would I create a bash script that does this for me? 1.1.1.1 2.2.2.2 If they where my IP lists then it ...
1
vote
1answer
41 views

Display a line in a text file if variable matches a part in the line?

I'm making a stock checker. I have a file with all of the NYSE exchanges and their descriptions. The descriptions start on the first tab enter of the file. The file formatting looks like this: A ...
2
votes
1answer
30 views

View remote value of $PATH inside shell script

When executing this bash script, it only shows my local path. ssh ${REMOTE_HOST} 'bash -s' <<EOL set -e source ~/.profile echo $PATH # Commands here don't work because $PATH is ...
1
vote
2answers
62 views

Bash script with data from another file

I have worked on the following script which I want to use to easily add multiple Postfix as well as a few other things. Below is a small sample postmulti -e init postmulti -I postfix-$new -e create ...
0
votes
1answer
32 views

How to escape an input string in Bash [on hold]

I'm using the jq tool to handle some JSON in bash. Just one problem, while using this line: PB_ACL="acl="`echo $IMGREQ | jq -r'.data.acl'` Result: echo $PB_ACL // acl= The expected value jq ...
1
vote
1answer
36 views

Find last line of a file for matching string?

I want a loop that runs infinitely over a file but always checks the last line to see if it contains the matching string if it does then echo that line and keep the loop running. What I have right now ...
4
votes
1answer
65 views

Is there a command line tool to manage unix signals?

Is there a command runner like env, nice, nohup, etc., that can run a program with modified signals? In my case, I need something to reset SIGINT to SIG_DFL. Why do I need this? Because ...
0
votes
2answers
22 views

Saving a piped value went wrong

I installed jq to handle some JSON with bash. But somehow piping the JSON string to jq in combination with saving it's output to another variable went wrong. TEST='{"foo": "bar"}' PB_SIG=$TEST | jq ...
0
votes
0answers
11 views

How to get back my splitted screen after I lost connection

I was executing the screen command with a splitted window in my CentOS server then I lost connection to it. I reconnected to my server and I did screen -r to get my screen back but now I don't see ...
5
votes
2answers
275 views

Why does `cat` seem to iterate over JSON arrays?

I'm puzzled by this behaviour of cat when trying to output a heredoc containing JSON in bash 3.2: input: $ cat <(cat <<EOF > {"x":[{"a":1,"b":2}]} > EOF) output: {"x":["a":1]} ...
10
votes
3answers
756 views

How to understand “cat > file_name << blah” command?

In following command cat takes the content of here-doc and redirects it to file named conf: cat > conf << EOF var1="cat" var2="dog" var3="hamster" EOF How to understand the order of ...
0
votes
2answers
44 views

viewing printf after pipe (or subshell?)

Ok, this is hard to distill to a single question because it really depends on how I'm going to troubleshoot it. The following script is meant to pipe mount.cifs commands to a while loop that enters ...
0
votes
1answer
30 views

Python output in XML format

I have a python script which compare IP list with IP Database and gives output of matching criteria. (I got the script from this forum). convert.py #!/usr/bin/python import socket,struct ...
1
vote
2answers
27 views

How do I generate diffs for a series of files?

I have a series of a few thousand files, all with filenames in order, so let's say file1.x, file2.x, file3.x, etc. All these files are in the same directory. I know how to generate a diff from ...
2
votes
1answer
88 views

g++ bash: warning: programmable_completion: g++: possible retry loop

When I type g++ and do tab completion for file listing, I get this warning **g++ bash: warning: programmable_completion: g++: possible retry loop** I googled it and so far no results . Can ...
-1
votes
2answers
56 views

bash scripting and PS1 prompt

Im trying to customize the way the PS1 prompt shows in terminal and CLI on Arch Linux, but it's not printing the proper thing it should be doing. First up is I'm trying to colorize parts of the PS1 ...
3
votes
2answers
54 views

command substitution: /dev/stdin: Permission denied

Want to read whole stdin into variable. Don't want to spawn new processes. From bash manual: The command substitution $(cat file) can be replaced by the equivalent but faster $(< file). It ...
0
votes
1answer
42 views

Binary not accesible from Bash despite being in path

I am learning how to program in Racket. It's binary is in "/Applications/Racket v6.2/bin/racket". Let me show what happens: MacBook:~ enedil$ echo $PATH /Applications/Racket\ ...
0
votes
1answer
25 views

How to kill only current process and continue with shell pipe-line?

I have 2 related Doubts about Bash. (Q1) Consider tail -f SomeFile | wc, a fictitious command-line, where tail is used to simulate a command (C1) which runs for a long time, with some output from ...
3
votes
3answers
90 views

How to kill this process in bash

I am trying to interface my homemade Raspberry Pi-powered arcade machine with a coin acceptor, and for that I: use a shell script (named gameplay) which starts the game emulator (MAME) when a coin ...
-2
votes
1answer
35 views

Execute bash snippets directly in shell? [on hold]

Is there any way to execute small bash snippets in the shell? If you don't want to edit a file again and again and test it by executing it again and again (in fact by jumping forth and back between ...
1
vote
2answers
23 views

bash command/script to reset default route

I manage several OpenWrt (embedded linux) routers for which I've written bash scripts to run an Openconnect VPN client. The client uses "vpnc-script" to set up routing, which replaces the initial ...
4
votes
3answers
272 views

Exiting a shell script with nested loops

I have a shell script with nested loops and just found out that "exit" doesn't really exit the script, but only the current loop. Is there another way to completely exit the script on a certain error ...
1
vote
2answers
33 views

how to use nohup while still sending stderr to the terminal

nohup automatically redirects stderr to stdout, but I want to send it to the terminal (it shows progress). How can I do that?
2
votes
1answer
36 views

Source .bashrc in zsh without printing any output

In the past, I've used bash consistently, because it's everywhere. But recently I started to try zsh. I don't want to give up updating my .bashrc fil which is rsync'ed to all my servers . So, in my ...
-1
votes
1answer
43 views

To sed if with and without conditions correct

I know that I may have the C package #include <stdint.h> in the first 1-30 lines. I would like to add it to lines where no previously if the file contains the word LARGE_INTEGER by GNU tools. ...
3
votes
2answers
53 views

How do I filter stdout of a program through grep while still controlling the program?

I'm trying to filter the output of the mpv media player, removing a particular line, but when I do so I am unable to control mpv with the keyboard. Here is the command: mpv FILE | grep -v 'Error ...
0
votes
0answers
15 views

Jumpimg between similar directories [duplicate]

My source and build directory structures are almost identical- /data/fs/src/lib/dedup/ /data/build/src/lib/dedup/ And I frequently navigate between them. It's painful to traverse up the parent ...
-3
votes
0answers
32 views

Detecting the newest file in a directory [on hold]

I need a Unix script to do the following (in bash) : Accept 1 parameter; (the parameter can only be bo or bot.) Change directory (at this time, this can be determined yourself for now); Detect the ...
1
vote
1answer
58 views

How to get last N commands from history?

I want to see what are the last N commands in my history. I thought history | tail -n 5 would make it, but I noticed that a multiline command counts for as many lines as it has. $ echo "hello how are ...
1
vote
2answers
60 views

How do I get the output of a program already running?

I have a python program that outputs to stdout and a log file. However, the person I am making this for wants to know if I can set it up so that he can see the output of the file, while it is ...
0
votes
3answers
50 views

Bash: increment a variable in a while loop?

Bash newbie here! I have a bash script that for each file in a set, greps each line in the file for a string. Then it splits the line on commas, converts the 7th element to a float, and increments a ...
0
votes
0answers
18 views

Why is Debian's PS1 variable different from the other distros? [duplicate]

I've noticed that Debian's PS1 variable is a little different. For example: root@debian:~# echo $PS1 ${debian_chroot:+($debian_chroot)}\u@\h:\w\$ What is this part: ...
1
vote
1answer
62 views

Ctrl-Y, emacs styled yank text is not working when user is switched

I cut the bash command line text using Ctrl-K. The line got cut. Now, I ran sudo su to become the root user. I tried to paste the command that i cut as non-sudo user using Ctrl-Y. It is no longer ...
4
votes
0answers
46 views

How can I make tmux tell bash to display the *logical* version of the current directory in newly opened windows?

Background I'm using tmux 2.0, Ubuntu 14.04.2 LTS in VirtualBox. In my ~/.tmux.conf file I have the line: bind c new-window -c "#{pane_current_path}" to make tmux open new windows with the same ...
0
votes
1answer
31 views

Linux: Test if in maintenance mode?

I want to run some things differently if I have booted into single-user/maintenance mode. I want to know how I can test in my .bashrc, in particular I would like to start tmux only in that mode, to ...
0
votes
2answers
46 views

How do I create a user bin directory in gentoo

I would like gentoo to allow users to have a bin directory which is added to the PATH variable for that user. The directory would be located at /home/user/bin. Where is the best place to set the PATH ...
13
votes
1answer
169 views

Update bash history on others terminals on exit of one

I know this question has a similar interpretation, as its asked here keep updating (and duplicated here). But what I'm trying to achieve is a bit different. I don't like the idea of my prompt ...
0
votes
1answer
18 views

Substituting the value with spaces for a variable in bash script - the correct way

I have a compilation script that can compile the program with and without the debug symbols. I want to ask via bash prompt ( read ) the user to choose whether he wants a debug version or not with ...
0
votes
1answer
29 views

Export mysql to remote server using one SSH session

I've come across a situation where I had to create a utilitary shell script that would be executed in many servers from different regions. The objective is to dump the local mysql database, copy it to ...
0
votes
1answer
46 views

Issue a command in each directory

I have 3 directories: dir1 contains two subdirs. In every subdir there is a slackbuild. I want to build all slackbuilds, staying in the parent directory. I have tried (cd *;sh *ld) But it only ...
1
vote
1answer
28 views

bash: Passing several space containing filenames

In a bash script I am rasterizing a PDF page by page into single files, in the end the single resulting PNGs are merged again into a PDF like this: convert -monitor /path/to/1.png /path/to/2.png ...