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

1
vote
1answer
18 views

How to sort files separatly without merging?

File1: Brazil New Zealand Argentina Uruguay File2: Chile Russia Latvia Switzerland I realize that the command sort -n File1 File2 will sort all the files merged together and display it ...
0
votes
0answers
22 views

better multiple replace with curly braces

for a single replace the curly brace works fine but i cant find a solution for multiple replace where is the trick ? or its not possible for multiple replace i use sed and for single the curly braces ...
0
votes
2answers
13 views

Execute vim in a loop

I am writing a script which will let the user edit more than 1 files. I'm trying to launch vim for every file. I've tried putting the filenames in an array and iterate over every element of array and ...
1
vote
2answers
15 views

bash case-insensitive commands matching

Is it possible for bash to find commands in a case-insensitive way? eg. these command lines will always run python: python Python PYTHON pyThoN
1
vote
1answer
16 views

Error while counting characters in a file

I have a source code to find a number of words and characters in a file: #!/bin/bash w=0 cc=0 for i in `cat $1` do j=$i echo $j w=$(($w+1)) c=`expr $j:'.*'` cc=$(($cc+$c)) done echo "no of ...
4
votes
1answer
127 views

Using expr, $(()), (())

In shell script we can substitute expr $a*$b with $(($a+$b)). But why not just with (($a+$b)), because in any resource it is written that (()) is for integer computation. So we use $(()) when ...
2
votes
1answer
26 views

How can I use sed to snip a line off of a string?

I'm writing a script to display the domain registrar info and I'm trying to snip off a few lines from what I already have I currently have it grabbing all the indented text from a whois. Now I'm ...
2
votes
1answer
18 views

Source of “gsed: can't read : No such file or directory”?

I have a Bash script that performs a simple substitution on OS X. Here's the reduced case: mkdir vs2005-dynamic cp cryptdll.vcproj cryptest.sln cryptest.vcproj cryptlib.vcproj dlltest.vcproj ...
2
votes
2answers
46 views

search contents of files that are packed in a zip file

For my school project i have to create a script that allows you to search the contents of files that are packed in a zip file. You can give a "search string" with the script, followed by one or more ...
1
vote
2answers
12 views

Change/edit text of whiptail gauge

I know that I can change the progress of a whiptail --gauge using something like: { for ((i = 0 ; i <= 100 ; i+=20)); do sleep 1 echo $i done } | whiptail --gauge "Please ...
0
votes
0answers
30 views

Bash: Regex for validating web URLs [on hold]

I have been trying to use the following REGEX in BASH or within PYTHON. Still no luck. ...
6
votes
4answers
241 views

Run command in bash after a certain length of time has elapsed?

If I'm executing a long process, is there any way I can execute some time-based commands? For example, I'm running a really long process which runs for roughly 10 minutes. After 5 minutes, I would ...
0
votes
1answer
17 views

Add time from all log files using bash

I want to extract time from all of my .log files and add all of these times into a single entity. My log files are placed in nested directories. Directory structure for my log files: |-- temp-system ...
1
vote
2answers
29 views

Double Click Shell Script in Ubuntu 16.04 Nautilus only gives the user option to edit the shell script file

When I follow the steps in [http://askubuntu.com/questions/138908/how-to-execute-a-script-just-by-double-clicking-like-exe-files-in-windows] I used to get a dialog box asking whether I wanted to ...
0
votes
1answer
34 views

have: command not found

I have created my own linux. Whenever I open up my bash and login into a sub-shell I get the following error -bash: have: command not found -bash: have: command not found -bash: have: command not ...
2
votes
0answers
22 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
2answers
44 views

Double variable substitution in bash

Program snippet: BASH_MIN_REQ="2.05" BINUTILS_MIN_REQ="2.12" BISON_MIN_REQ="1.875" BASH_CURR=$(bash --version | head -n1 | cut -d"(" -f1 | cut -d" " -f4) BINUTILS_CURR=$(ld --version | head -n1 | ...
1
vote
1answer
36 views

How to compare a program's version in bash?

Suppose I want to compare gcc version to see whether the system has the minimum version installed or not. To check the gcc version, I executed the following gcc --version | head -n1 | cut -d" " -f4 ...
0
votes
0answers
14 views

How to fix bash profile display [on hold]

I have a custom bash profile set up with bits and pieces cribbed from other people. I have a display bug that I can't seem to figure out. I'm going to run through the set up that I think is relevant ...
1
vote
1answer
14 views

View path options when using readline?

When I am typing in a path at the bash prompt I sometimes do not remember what the directories are so I cannot incrementally search for them. Is there a way in readline to cycle through the ...
2
votes
1answer
70 views

what is the difference between “./command” and “bash command”

I have simple bash script file, it contains only one line: rvm gemset use --create 2.0.0@PRJ_NAME If I run this script with: ./scriptname.sh I get a well-known error message from RVM RVM is not ...
1
vote
0answers
13 views

Vagrant ssh closes connection after executing -t option

I'm trying to create a script that will bring up my vagrant VM (a Ubuntu box hosted on OSX) navigate to the correct directory and start up my virtual env. I've read that this command should work for ...
-3
votes
1answer
24 views

I cant cd hidden files/dir

I have been working on git a little bit and i tried to cd into /home/pi/Desktop/python_git/.git But it complained there was no directory called /.git. I know that this is because it begins with a . ...
1
vote
2answers
43 views

Use variables in here-string

To feed input to an interactive script, I've been using a here-string: script <<< $'1 2\n3 4\n5 6\nq' This effectively enters 1 2 3 4 5 6 q into the script. But how can I replace one of ...
2
votes
2answers
24 views

Use previous “path” in a command [duplicate]

A couple of years ago, a former coworker told me a trick in Bash that I completely forgot how to do it. The idea is that when you type a path, in the next command you can use some shortcut to ...
1
vote
0answers
15 views

Record fullscreen program with avconv/ffmpeg?

I'm trying to record a fullscreen program (snes9x) with avconv, aka ffmpeg. I have avconv set up to use my whole screen, but it doesn't capture snes9x when I run it. #!/bin/bash avconv \ -f ...
0
votes
2answers
29 views

simple for loop script to build out ipv6 subnet

I am trying to use nmap to scan a /119 IPv6 network. (512 addresses). Before I do this I want to generate a file that will populate all of the ip addresses in that range. The network info is as ...
1
vote
0answers
16 views

detecting sound from speakers

I have decided to make a radio from my old laptop. I installed Puppy linux and set special features, like: after waking up, it turns on my favorite online radio (openFM) and switches off the screen. ...
3
votes
1answer
21 views

SLURM: Custom standard output name

When running a SLURM job using sbatch, slurm produces a standard output file which looks like slurm-102432.out (slurm-jobid.out). I would like to customise this to (yyyymmddhhmmss-jobid-jobname.txt). ...
3
votes
2answers
50 views

Find IP addresses visiting /page1 but not /page2 from nginx access logfile

I need help with selecting specific data's from log files. I need two scripts: I need to select all IP addresses that only visited /page1 I need to select all IP addresses that visited /page1 but ...
3
votes
1answer
18 views

bash: Cancelling the execution of 'trap handler DEBUG'

I can get a function myHandler() to execute before a bash command by doing the following: function myHandler() { ... } trap 'myHandler' DEBUG However, I'd like to be able to proceed with or ...
1
vote
1answer
25 views

“nan” coming up in RRDTool

I'm getting a lot of NaN values being drawn on my RRDTool graphs and I can't understand why. My script to populate the RRAs in the RRD: #! /bin/bash LOAD=`cat /proc/loadavg | awk '{print $1}'` ...
0
votes
0answers
23 views

How to send and receive files through given channel by scp in putty [on hold]

Suppose we have Putty and some bash-script on the remote cluster. First I send the file from my machine through putty. Once the file is received by cluster, the script starts to run. It generates some ...
1
vote
1answer
26 views

SSH, Putty and sending data on the cluster

I have ssh access to the cluster through Putty. I also have the script, which, after its launch, makes some commands, generates data and sends it via email. Is it possible to provide following: I ...
3
votes
2answers
33 views

How can I move files into subdirectories by count? [duplicate]

I have around 100,000 files in a directory. As you can imagine, that's not an ideal situation, and I'd like to split the directory up into subdirectories. But the filenames aren't such where I can put ...
2
votes
1answer
55 views

Bash completion extra words Fedora 23

I am new to using Linux. :) Today I noticed some extra words when TAB completing dnf search. I am not sure how to google this (I tried, but with no success), so please help. :D Anyone has any idea ...
1
vote
1answer
37 views

Send array to subshell function with pipe?

I really need to get an array to a subshell so the processes can run together in one script. I know I cannot export an array but is it possible to send it through a pipe to a subshell, and how would I ...
2
votes
0answers
32 views

cd with double slash hangs forever on Mac OS X Terminal

If I type cd // on the Mac OS X Terminal (Version 2.6.1 (361.1)), the prompt hangs forever. Why? Curiously that doesn't happen if I do cd / or cd ///. I am using El Captain with the bash that comes ...
1
vote
2answers
28 views

replace the content of one field based on the content in another field

I would like to divide the first column based on the delimiter, here -. Based on the last value, last column, here column 2, should be populated. If the value is 01 or 99 then replace with 2 or 1 ...
2
votes
2answers
43 views

Bash script to count file types in a path (including subfolders)

I would like to get a quick overview over the different file types in a directory (including all its subdirectories) using the file tool, e.g. telling me what file type is the most common one there. ...
1
vote
2answers
414 views

How to execute “Yes/No” operation as long as I press “Yes” in bash?

Suppose I have the Yes/No construction in bash script: read -r -p "Yes or no?" response if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]] then do ... else exit 0 fi I want this construction to be ...
0
votes
1answer
29 views

In tmux how do I create a new pane with the right pwd while running a command in the parent pane?

If I create a new pane B from pane A and I'm not running any commands in A then B gets created with the same pwd as A which is what I want. However if while creating the new pane I'm running a bash ...
0
votes
1answer
28 views

How to compare current date and date from line in txt file?

I want to check when week left before the certificate expires for our users on Openvpn server. On server installed Centos 6.7. I can export enddate and subject from all .crt to txt file with the ...
0
votes
0answers
35 views

Send command to open process in Shell file

In bash how can I issue a command to a running process I just started? For example; # Start Bluez gatttool then Connect to bluetooth device gatttool -b $MAC -I connect # send 'connect' to the ...
0
votes
0answers
38 views

Array value won't get printed out

I have the below bash script, but rather that I get the command executed stored in cmd[1] it prints [1]: command not found. I executed the command with the following way: $ qsub -J 1-33 sicer-pbs.sh ...
0
votes
1answer
29 views

How to prevent .bash_history from being used to rebuild history

We use custom history files which get backed up per user. When someone does a history -c we notice that after they log back in there is history in the buffer again and it seems to come from ...
13
votes
1answer
303 views

exec and tee to the logfile: explain these bash commands

I saw this at the top of my bash script file: export LOGFILE=$LOGDIRECTORY/${SCRIPT_NAME}.log exec > >(tee $LOGFILE) exec 2>&1 What does it do? What are two exec processes doing here? ...
0
votes
2answers
22 views

Listing numbered files using wildcard sequence with predefined range

I have a folder of numbered data files. I am trying to incrementally extract a predefined range of files. The range of files that I am looking for is predefined in two variables, ns and ne, which ...
0
votes
1answer
39 views

Few questions about realization of commands using bash scripts

I'm the newbie into scripting, so, please, sorry for annoying questions. I need to create bash script file, which after its launch does following. 1) Suppose after launching the script I enter the ...
1
vote
1answer
47 views

Exiting a shell script if certain child processes exit

I have a Bash script that starts one web server, does some work, and then starts a second web server. I would like the script to exit, and for both of these servers to be terminated, if either server ...