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.

learn more… | top users | synonyms

0
votes
1answer
31 views

What are the possible correct combination for std-out(2) and std-err(1)?

sqlite -echo test.sqlite < test44.sql > test44.out 1>&2. sqlite -echo test.sqlite < test44.sql > test44.out 2>&1. I used the first command to get an output of (stdout and ...
0
votes
0answers
13 views

Arguments following `bash -c` [duplicate]

From Bash Manual, bash -c Read and execute commands from the first non-option argument after processing the options, then exit. Any remaining arguments are assigned to the positional ...
0
votes
1answer
61 views

Script wont return when executed via SSH

I am calling a script via ssh client like this: ssh root@host "su - oracle -c '~/bin/weblogic start'" The ~/bin/weblogic is a bash script that actually starts the web server in the background and ...
1
vote
1answer
36 views

Formatting issue

I have a small script like below, where output gets highlighted (in red,yellow etc) on screen if there an issue normal=$(tput sgr0) red=$(tput setaf 1) yellow=$(tput setaf 3) df -h >/dev/null 2&...
0
votes
1answer
60 views

Why isn't ~/.bash_profile executed when starting Ubuntu?

I installed Ubuntu in Virtualbox in a MacBook Pro laptop. In ~/.bash_profile, I added some directories to PATH. But after I reboot the guest Ubuntu, the added directories are not in PATH. I wonder why ...
-3
votes
2answers
71 views

find all files excluding one directory

so I want to clean a directory before I start work. I looks a bit like this. ./static ├── css │   └── styles ├── img │   └── pictures └── js └── scripts I want to rm the contents of css and js ...
1
vote
1answer
34 views

how to search file for begin of string and save a variable

i am trying to find a way of searching a file for string, it needs to work by searching then file and if any line in the file begin with what i am searching for, then take that whole line and save it ...
0
votes
0answers
35 views

How to Rename files in subfolders with subfolder name? [duplicate]

The directory structure is as follows: PWD/ A1/ acc.bam A2/ acc.bam A3/ acc.bam A4/ acc.bam All the acc.bam files should be renamed with subfolders names. For eg: "acc.bam" ...
1
vote
1answer
31 views

Readline bindings not working with Control and Shift modifiers

I'm tweaking with GNU Readline's key bindings in Bash. Specifically, I wish to achieve the following mapping effect: Control' ==> 'I' ControlShift' ==> "I" Control` ==> `I` Control[ ==>...
2
votes
3answers
251 views

Hide ones command history from other users on a Linux server

When I log in via ssh on a Linux(Ubuntu) server, I notice that all the bash commands executed by other users on the server are saved in the command history. Is there a way that could allow me to hide ...
2
votes
1answer
51 views

GNU Parallel: How can I reference array elements?

This is my case scenario: luis@Balanceador:~$ echo ${array[@]} a b luis@Balanceador:~$ echo ${array[1]} a luis@Balanceador:~$ echo ${array[2]} b luis@Balanceador:~$ parallel echo ${array[]} ::: 1 2 -...
0
votes
1answer
32 views

how to get the standard output from command in variable

when we want to know what is the standard output of the ssh then we do ssh $linux_server "cat /proc/uptime" [[ $? -eq 0 ]] && ssh is ok but how to know the ssh standard output in case of ...
-4
votes
3answers
43 views

Bash - Print lines containing at least all vowels in any order but no consecutives [solved]

The problem is to write a script that takes a file as argument and prints all the lines that contain -at least- all the vowels , -regardless of ordering-, but with [no two same consecutive vowels]. e....
0
votes
1answer
59 views

How to compare two variables containing ipv6 addresses?

I have to compare two variables with ipv6 so there are strings and integers together. I tried it as below: if [[ "$ipvsrc" -eq "$ipvdst" ]]; then echo -e "Value OK"; fi error output was: ...
-1
votes
0answers
16 views

How to run a function for a specific received packet? [duplicate]

I am doing an experiment for my master thesis. I want to run a function (e.g. multiply two numbers) when a specific packet is received (e.g. a packet with destination TCP port 6666). For example, I ...
5
votes
1answer
244 views

Newline (“\n”) before output in bash

I want to modify my output in bash for better view of output. Simply put \n before this. How can I change it in .bashrc? For example: It's default: root@comp:$ abc bash: abc: command not found I ...
2
votes
1answer
38 views

How to suppress echo of buggy read function

I'm trying to capture a key press in a shell script (e.g. using read) and not to echo it. The three methods I found were stty -echo, the -s switch and stream redirection. However, on macOS, which ...
1
vote
1answer
29 views

Different command outputs

I entered same command with a variable host. During 2nd time I entered blank space between host,= and $. Why it was trying to connect to a server ? Also, when I write like $(host name), I am getting ...
3
votes
1answer
20 views

How can I escape an exclamation point in the PS1 environment variable?

It is substituted with the history number even if I try to escape it with a backslash.
4
votes
2answers
61 views

Compose string of IPs using bash command line

I have a command that returns the following: id1="172" id2="17" id3="136" id4="5" id5="0" /> id1="172" id2="17" id3="128" id4="2" id5="0" /> id1="172" id2="17" id3="128" id4="4" id5="0" />...
0
votes
2answers
46 views

Out-putting the results of a nested for loop to a file in bash

I am new to bash and I have been attempting to create a file out of my loop in bash , I was successful in generating the file with the following code for ((i = 0; i <= 5; i++)); do for ((j = i; ...
2
votes
2answers
45 views

Get only the size of a mounted filesystem

I want to get only the total size of a mounted filesystem. But the catch is that I only know about the mount point. So, I thought of using the df command. To get the size of this mounted filesystem, ...
1
vote
2answers
32 views

Generating strings of words with space delimiters from cut statement

I am new to bash. When I run the following command: grep "type" /root/myFile | cut-d'=' -f2 I get the following: 102 304 503 442 I want to store the contents of the first command into a ...
-1
votes
1answer
48 views

how to write own shell that works with ssh [closed]

I tried several tutorials I modified usermod -s shell path_to_binary username it does not work thru winscp, but works if use from Ubuntu terminal I want to own shell, where I can control over ...
3
votes
2answers
783 views

Bash - “/” is a directory

This is really confusing... I currently have a Debian 8 computer, and I connect to it using PuTTY (SSH). The default console used is Bash. When I try to pass a path to an alias, it gives the ...
1
vote
0answers
14 views

Wacom Linux xsetwacom Attach Shell Script to Buttons

Using Inutos Pro with Manjaro. Would like to attach a shell/bash script to one of eight buttons. Script would be something along the lines of 'dolphin Documents'. Can xsetwacom do this?
0
votes
0answers
19 views

how to get a “parent-child” relationship with tmux panes and windows

Essentially I'm trying to mimic fork when I split a window or create a new one from an existing tmux session. For example lets say you enter a shell in gnome-terminal and then launch a new gnome-...
0
votes
1answer
27 views

PROMPT_DIRTRIM not working

I have the following in my .bash_profile: PROMPT_DIRTRIM=3 export PS1='$ \u in \w: ' However, when I navigate deep within a directory, the path doesn't shorten. This is what the prompt shows: $ ...
1
vote
0answers
13 views

qsub launch a job from node

I have a pipeline that is launched using a command. For some admin/server reasons, that tool has to be launched from a node. That tool triggers all the steps from my pipeline in a file called pipeline....
1
vote
1answer
37 views

Possible to reuse first argument of BASH line in the same line?

I do this in BASH echo test "$1" ..expecting to get.. test test ..but I get.. test Is this something possible to do? It would make my life easier since having a list files I could do ...
0
votes
1answer
18 views

Puppy precise - sudo command not found on bootable CD

I downloaded the .iso file and burned it to a rewritable CD. But when trying to install a PHP server (xampp) from the command line, as instructed in http://wikihow.com/Install-XAMPP-on-Linux my puppy ...
1
vote
0answers
45 views

Howto terminate xvfb-run properly

In order to perform some JavaScript unit tests with karma inside a docker container (based on ubuntu 14.04) I'm starting firefox in the container using a karma-script-launcher with xvfb-run. The start ...
1
vote
1answer
46 views

Can I open terminator with one windows with bash and another with fish? [duplicate]

So I am running terminator 0.98. I like fish shell but for some task it is handy to have bash (like for virtualenvwrapper). So I now have two windows that open when I start terminator. But I would ...
1
vote
0answers
23 views

Ordering of files opened by program

When I open a set of files, usually just by using a glob character to open all the files in a directory or a subset, typically if not always the default is for the files to be opened by alphabetical ...
1
vote
1answer
49 views

Extracting from Logs

Actual logs are: 2016-06-19 22:08:09 [213917] 1bEgCe-000tZR-E9 ** saadia@aol.com (fahad@manakintextiles.com) <fahad@manakintextiles.com> F=<james@designplus.com> P=<james@designplus....
-1
votes
1answer
57 views

Nested for loop in bash

Hello I would like to ask you, how can I write the same exact loop in bash for (int i = 0; i < a; i++) { for (int j = i; j < a; j++) { System.out.println(i + " " + j); } }
3
votes
0answers
77 views

wait bash-builtin burns a CPU at 100 percent

Occurs at least on GNU bash version 4.3.42 x86_64 && GNU bash version 4.3.11 x86_64 I use sleep & wait $! instead of a simple sleep for getting an interruptible sleep by a signal (as ...
-1
votes
1answer
60 views

Problem Counting the lines of a text file

I want to be able to get the number of non-empty lines in a text file. Suppose I have num.txt with the contents: 10 10 12 15 24 31 32 Here there are 8 lines, with only 7 that are not empty. How ...
1
vote
1answer
39 views

Compare dates in a list

So I have a list of dates and I need to develop a script that keeps a rolling count of how many dates are older than 14 days (date --date="14 days ago" +%Y%m%d). Not sure how I can have the date check ...
1
vote
2answers
66 views

Keyboard shortcuts C-h, C-m in bash [duplicate]

Bash uses GNU Readline. Readline provides a collection of keyboard shortcuts. However, there are some shortcuts that work on bash and that are not documented in Readline reference. Some examples are: ...
0
votes
1answer
40 views

What's the proper way to read stdin inside parenthesis assignment of 2nd pipe

1st style, group 2 pipe to assign, this works: $ myresult1=$(curl -L 'https://archive.org/wayback/available?url=stackoverflow.com' 2>/dev/null | jq '.archived_snapshots.closest.url'); echo "$...
3
votes
2answers
173 views

what is $$ in bash? [duplicate]

there is a script I evolved with it, it has line of command like below : mytemp=`echo ${sourcedir}|awk -F/ '{printf "/%s/tmp",$2}'`/`basename $0`-$1.$$ at the last of the command we see $$ that ...
1
vote
2answers
54 views

Can I use a shebang to have a file source itself into current bash environment?

I have a growing collection of scripts which should be sourced, not run. At the moment they have the shebang #! /bin/cat but I would prefer the have them be sourced into bash when run, in the same ...
2
votes
1answer
26 views

How to properly use “complete -G”? [duplicate]

I've generated the simplest code I could think of to illustrate my problem. Suppose I want the "foo" command to work with files that end with ".cc". complete -G '*.cc' foo Now let's suppose my ...
1
vote
2answers
37 views

Autocomplete hostnames when using SSH within history file

I'm looking for a feature that help me to autocomplete the servers I "sshed" in sometime and are in my .bash_history file without messing with known_hosts file or /etc/bash_completition, just grab ...
1
vote
0answers
20 views

Changing CentOS 7 machines disables terminal access during background task

Based on this other posting, I typed the following command into a CentOS 7 terminal on a devbox that has the gnome GUI, and was able to continue to use the terminal for other commands while the ...
0
votes
1answer
28 views

joint two conditions in bash script

Note: Update Jun 28 I have an iptables script.sh (interpreted by bash) with the rules: function run_ips(){ for ip in $(sed '/#.*/d' ips.txt); do if echo $ip | grep -q "-" >/dev/null; then ...
2
votes
1answer
33 views

Bash, fork with CLOEXEC

Can Bash execute a subprocess while preventing a subprocess from inheriting a file descriptor? if flock -nx 9 then # If begin program runs away, it will keep the lock. begin program else echo "...
0
votes
1answer
22 views

Bash PS1 Doesn't Evaluate Variables

I'm trying to set my PS1 prompt to /usr/local/src mario So I've used the following code inside of .bash_profile: export PS1=" \w \u\[$(tput sgr0)\]" And I end up with: \w \u\[$(tput sgr0)\] ...
44
votes
8answers
4k views

Why does Bash's source not need the execution bit?

with Bash's source it is possible to execute a script without execution bit set. This is documented and expected behavoir, but isn't this against the use of an execution bit? I know, that source ...