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

0
votes
0answers
24 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 ...
1
vote
0answers
18 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
34 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
22 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 ...
1
vote
3answers
63 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 ...
5
votes
3answers
424 views

Why is the manual for 'where' command not available

I recently came across the command where, which provides the actual path of executables in Linux. I was aware of which, whereis, locate and find, but not where. I want to know when this command got ...
-2
votes
1answer
32 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
17 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
259 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
32 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
32 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
51 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
54 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
59 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
48 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
59 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
43 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 ...
12
votes
1answer
126 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
27 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
27 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 ...
4
votes
3answers
88 views

-bash: unalias: ls: not found

I am trying to install tomcat 8 on centos 7. I am using the terminal as root. When I type in source ~/.bashrc, the terminal gives back the following error: -bash: unalias: ls: not found. How can ...
1
vote
1answer
43 views

Syntax error at a semicolon in a shell script

The one liner command will be longer but this is the part that is throwing the error. for user in natural1 ; do cat <<EOT >> /home/$user/public_html/.htaccess <FilesMatch ...
0
votes
2answers
75 views

Special meaning of '{}' ';' with find

User-define action is a feature of Bash in linux. In Linux terminal if I write root@localhost: find ~ -type f -name 'foo*' -ok ls -l '{}' ';' then it checks if there is any filename starting with ...
-3
votes
0answers
55 views

Bash Shell - Grep a line from a file - append from an entered variable and query that line?

I would like to grep a line from a txt file use that line and append the variable used "entered from the user. Get the output of the grep add variable with a space and then query that line. Any ...
2
votes
1answer
63 views

Convert IP Address to Coordinates using database

I have a file which contains IP and I wanted to compare it to Coordinates using a local database (instead of API). I tried following a process and break down to pieces and created scripts referring ...
2
votes
1answer
61 views

How can I run my program without having to type ./?

My teacher wants to be able to compile our programs without having to type ./. For example we would write: g++ some_program.cpp -o some_program some_program He says to type: cp .bash_profile ...
0
votes
1answer
36 views

why are colors mixed up in CentOS 7 terminal?

I have CentOS 7 running as a guest OS inside a VirtualBox host. I opened a terminal to write some commands, but the colors are all messed up as shown in the following print screen: It looks ...
5
votes
6answers
481 views

How do I check if a variable exists in bash?

I need to check a variable's existence in an if statement. Something to the effect of: if [ -v $somevar ] then echo "Variable somevar exists!" else echo "Variable somevar does not exist!" ...
-1
votes
2answers
35 views

Enter a variable into a command in bash

My question should be simple for you guys. I am writing a simple script that runs a command but the file it would need is always different. Is there a way for it to ask: "Where is the file?" And ...
0
votes
2answers
33 views

Replace spaces by underscores in files: Error in my bash script

I don't understand the error in my bash script. #!/bin/bash newFile="" for file in * do newFile={$file/ /_} # so as to replace spaces with underscores mv {$file} {$newFile} done It ...
2
votes
2answers
64 views

Compare 2 Files if it falls between a range of numbers

I have 2 files, File 1: 4 7 2 File 2: 1 5 Alpha 6 10 Bravo 11 15 Charlie 16 21 Delta 22 30 Echo I want to compare every entry in file 1 if it lies between col 1 and col 2 of file 2 (should be ...
0
votes
2answers
57 views

How to execute multiple .command files simultaneously?

I have a folder of .command files (regular task) on Mac OS X , which i would like to execute simultaneously. At the moment, i have been iterating through each file in the directory one by one to ...
0
votes
4answers
31 views

Test if integer series is strictly increasing

I would like to test if a list of integer values (e.g stored in a file, one per line) is strictly increasing, using a bash script. Is there any simple/concise way to achieve that?
1
vote
0answers
18 views

GNOME 3.14+ launch new gnome-terminal and set title

To the disappointment of many, tab/window title can't be set anymore with --title I use bash. I have had a few aliases I have used to connect to remote servers with. alias c:prod='gnome-terminal ...
1
vote
3answers
196 views

Put big data of heterogenous byte offset into arrays by AWK

Assume the data consists of byte offset which is not fixed i.e. the distance of two subsequent file headers varies. The point of this thread is to go through each size of events separately in arrays. ...
4
votes
2answers
97 views

How to search for and replace text between two markers in bash script, with content from another file?

Say I had a block of text in the ~/.bashrc: #~/.bashrc # ...some commands... # aliases alias suicide='sudo rm -rf /' # end aliases # other commands I wish to replace that block of text with some ...
4
votes
1answer
32 views

Aliases fail to persist after sourcing script

Here is my script: echo "Defining aliases" echo $$ echo " s=screen v=vlock -a j=jobs " | sed '/^$/d' | while read alias do echo $$ alias "$alias" alias | wc -l done And here is its output: ...
0
votes
1answer
17 views

Comparing Oracle version in bash script

I'm trying to create a bash script to install an application that requires Oracle 11g client. How can I read in the version info within the bash script? sqlplus when run in Putty spits out the ...
0
votes
0answers
32 views

How to get the placeholder's value which is stored in a different file (same directory) [closed]

With the conditions: I cannot use any XML parser tool as I don't have permission , read only My xmllint version does not support xpath, and I cannot update it , read only I dont have xmlstarlet and ...
0
votes
2answers
68 views

PATH variable is not working [closed]

I'm trying to set up PATH like this: export AMBERHOME=/home/pablo/amber14 PATH=$AMBERHOME/bin:$PATH PATH=$PATH:/home/pablo/tinker/bin However the PATH variable seems not to work properly. I dont ...
4
votes
2answers
40 views

How can I disable bash traces?

For any command that I execute in the terminal a comment like + command appears. For example for ls it shows + ls --color=auto.
1
vote
1answer
25 views

Magic environment variables in gnome-terminal

I had installed a proxy software (cntlm) on my machine. It sets the environment variable http_proxy to 127.0.0.1:3128. Now I've uninstalled the program using apt-get remove cntlm. However I'm able ...