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
2answers
37 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
40 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
46 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
754 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 ...
0
votes
0answers
29 views

How can I customize output of a command? [closed]

One of my friends asked me how to customize the output of a command & I thought a bit but I can't find an acceptable answer. ( For example adding * at the start of every output of the find ...
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
16 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
19 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
11 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
33 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
13 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
21 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
34 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
21 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
45 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
56 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
68 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
58 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
37 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
65 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
39 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
165 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
44 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 ...
-6
votes
0answers
33 views

Write a Shell Script to generate a report named “Report_DDMMYYYY_HHMMSS.log” [closed]

Write a Shell Script to generate a report named "DD_MM_YYYY_HH_MM_SS.log"which performs the following operations: 1) ** Display the number of files present in the given directory (Directory name ...
2
votes
1answer
24 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
33 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
16 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
22 views

joint two conditions in bash script

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

How to get specific information out of /etc/passwd and display it into a file? [closed]

Alright so I posted a previous POST which I figured out half my problem which I had was to get information like the user, hom dirs and bins to show and display out of /etc/passwd, this was done by: ...
2
votes
1answer
25 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
12 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)\] ...
39
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 ...
0
votes
1answer
35 views

Rsync to copy specific subfolders and files to new directory

Original path, RootFolderI: RootFolderI/FolderA/Subfolder1/Subsub1/JPG1.jpg -> want this jpg RootFolderI/FolderA/Subfolder2/Subsub1/JPG2.jpg -> want this jpg RootFolderI/FolderA/Subfolder2/...
-1
votes
1answer
30 views

source command doesn/t work when used inside shell script

I am using an installer which is adding an environment variable in the ~/.bash_profile file. When I'm starting the jetty server, it is unable to find that entry... When I run $ source ~/....
3
votes
2answers
36 views

Can terminal window titles be updated while a process is running?

I'm trying to set a little pomodoro/countdown timer for myself in the terminal. This comment on Superuser offers a handy little shell function that will act as a countdown timer, which printfs the ...
3
votes
2answers
38 views

Is there a shortcut to rerun a command with arguments from last command (not cd, ls or echo)

Searching through passed Logfile with something like this: cat /path/to/logfile | grep -iEw 'some-ip-address-here|correspondig-mac-adress-here' This gives me all the passed log lines until now so ...
2
votes
2answers
44 views

Command behavior is different when executed by an other user (via su -c)

I want to kill every processes who match a specific chain. Here is my script, which works pretty well: echo `ps aux | grep verySpecificChain | grep -v grep | /usr/bin/awk '{ print $2 }'` | xargs kill ...
10
votes
2answers
430 views

View a range of bash history

The history command lists out all the history for the current session. Like: 1 ls 2 cd /root 3 mkdir something 4 cd something 5 touch afile 6 ls 7 cd .. 8 rm something/afile 9 cd .. 10 ls 11 history ...
0
votes
2answers
29 views

Passing variables to script [duplicate]

What is the difference between: ./script.sh "$VARIABLE" and ./script.sh ${VARIABLE} Is there any?
1
vote
0answers
41 views

Smart case completion in Bash?

In Vim, one can combine the following commands, :set smartcase + :set ignorecase, to make searching case-insensitive unless there is a capitalized letter in the search query, in which case it is case-...
0
votes
0answers
53 views

I cannot type the letter 'l' in terminal on mac

I can type the letter L on any other applications except for within the terminal. I was wondering whether it would have something to do with the bash setting in .bashrc. I am running Ubuntu.
1
vote
2answers
51 views

parallel processing using xargs

How to execute a bash script in parallel for each line ? Actually, I will be tailing to log file and for each line found, I want to execute script in background something like below: tailf logfile....
2
votes
0answers
66 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 ...
0
votes
1answer
61 views

cat specific line range from /etc/hosts to dialog box

I need help with dialog box in bash. I like to list, for example all Ethernet switches from /etc/hosts and show them inside dialog box. After that I would like to connect selected switch from the ...
1
vote
2answers
42 views

Defer variable expansion to subshell

My service uses environment variables extensively for configuration (mostly because it's really easy to inject those into a Docker container). I also have some maintenance scripts that I can run ...
2
votes
1answer
44 views

One of several file-append redirections of “python --version” is repeatably 'overlooked' by bash, but the others aren't [closed]

Why is bash consistently passing one, specific redirected output from python --version to the console rather than appending to file, while every other output is redirected properly? I am developing a ...
0
votes
0answers
25 views

Shell syntax var=${var:-$var2/file} [duplicate]

I came across the following syntax while working with some shell scripts. I am unable to understand what it does and I am not sure what should I search to get right documentation for this var=${var:-$...
24
votes
1answer
2k views

If “bash <file>” works, why is “source <file>” throwing an error?

I have the following script: #!/bin/bash set -x if :; then echo a fi If I run bash /tmp/file, a is echoed, but if I run source /tmp/file, I get: bash: /tmp/test: line 6: syntax error: ...
0
votes
1answer
200 views

Echo semicolon in bash

I am trying to write to a file the following string: 1;2;3;4. The semicolons create problems. I have been able to figure out the following ecamotage to do it: variable='1;2;3;4' echo "${variable//;/\...