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
0answers
6 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
20 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 ...
4
votes
2answers
845 views

What are the new features available to bash 4?

I was using bash3 up to now, and just got a copy of the latest version $ ./bash --version GNU bash, version 4.1.0(1)-release (i686-pc-linux-gnu) Copyright (C) 2009 Free Software Foundation, Inc. ...
2
votes
2answers
39 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
0answers
10 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. ...
1
vote
2answers
36 views

unix - select specific lanes from logs

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 ...
1
vote
0answers
8 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). ...
2
votes
1answer
12 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
0answers
15 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
4answers
759 views

Unset http_proxy enviroment variable

Updated 11/03: After doing some test with your suggestions, I only can be sure about one thing: there is something related to the graphical environment, because if I login through ssh or using ...
1
vote
1answer
23 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
3answers
881 views

How to open process substituted file from php?

Here's what I tried to do myself: $ type 1.sh #!/bin/bash -eu php -r 'var_dump(file_get_contents($_SERVER["argv"][1]));' -- <(echo 1) $ ./1.sh PHP Warning: file_get_contents(/dev/fd/63): failed ...
2
votes
1answer
34 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 ...
0
votes
0answers
21 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 ...
11
votes
1answer
164 views

Why do these bash fork bombs work differently and what is the significance of & in it?

I get how a normal fork bomb works, but I don't really understand why the & at the end of the common bash fork bomb is required and why these scripts behave differently: :(){ (:) | (:) }; : and ...
9
votes
4answers
2k views

Glob with Numerical Order

I have this list of pdf files in a directory: c0.pdf c12.pdf c15.pdf c18.pdf c20.pdf c4.pdf c7.pdf c10.pdf c13.pdf c16.pdf c19.pdf c2.pdf c5.pdf c8.pdf c11.pdf c14.pdf c17.pdf c1.pdf ...
0
votes
3answers
2k views

VLC script on ubuntu server

I need a small script which run three vlc command on the same time (on Ubuntu server 14.04) as stated below: #!/bin/sh cvlc -vvv v1 --sout ...
3
votes
3answers
2k views

Query list of servers for memory/cpu allocated

Running RHEL 6.2, trying to write a bash script to SSH to a list of remote servers, and write the CPUs and Total Memory to a file, one line per host in the following format: HOSTNAME1 CPUS: 12 ...
3
votes
2answers
29 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
0answers
26 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
61 views

forward aliases to child process

I have some aliases which are defined in /etc/zprofile (or /etc/profile for bash). Also $PATH gets manipulated there. I want to start an interactive shell from a shell which avoids the $PATH ...
12
votes
1answer
282 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
1answer
30 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 ...
8
votes
4answers
6k views

Hybrid code in shell scripts. Sharing variables

This answer discusses how to run a multi-line Python snippet from the command line in a terminal. I noticed that the answer works great within shell scripts, even with nested indentation, which is ...
90
votes
3answers
54k views

Why does my shell script choke on whitespace or other special characters?

Or, an introductory guide to robust filename handling and other string passing in shell scripts. I wrote a shell script which works well most of the time. But it chokes on some inputs (e.g. on some ...
1
vote
2answers
406 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 ...
1
vote
2answers
26 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 ...
0
votes
1answer
23 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 ...
5
votes
2answers
1k views

Can I set a bash timeout only for virtual consoles (ctrl+alt+{f1-f6})

I know that I can set a TMOUT variable to automatically end a bash session after a specified period of inactivity. However, what I want is to apply that only to my 6 built-in virtual consoles, which ...
0
votes
0answers
37 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
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
1answer
27 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
2answers
59 views

How to process a file containing quotes?

I know a fair bit about escape characters in BASH. I know that \ will escape the next character, " " will escape all characters except for $ and ", and finally ' ' will escape all characters except ...
-1
votes
2answers
73 views

Have sed echo string after match

I need to have the string directly following/pbs.twimg.com\/profile_images\/echoed out. This is for a search tool I have created with a bit of help, and everyone recommends sed, but I never really use ...
4
votes
4answers
47 views

Does \ work for escaping functions?

I have a function defined in my .bashrc that I would like to bypass: function func() { // func } export -f func When I run env -i func I can access the func command without the function in the ...
1
vote
1answer
45 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 ...
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 ...
61
votes
5answers
194k views

How to append multiple lines to a file with bash

I am writing a bash script to look for a file if it doesn't exist then create it and append this to it: Host localhost ForwardAgent yes So "line then new line 'tab' then text" I think its a ...
6
votes
4answers
411 views

How can I use '*' to capture everything with exceptions

For example, I have files named A_1.txt A_t_1.txt A_ts_1.txt A_tsa_1.txt in a directory ~/admin/packages/. I am building a for loop to by globbing to A_1.txt for f in ~/admin/packages/*_1.txt ...
3
votes
2answers
3k views

difference between `for i in {1..$N}` and `for i in $(seq 1 1 $N) ` [duplicate]

I have the following in a script: #!/usr/bin/env bash ... for i in {1..$N} <loop content> The above doesn't work and is only executed once where i has the value {1..5} (if 5 was provided ...
0
votes
2answers
21 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
2answers
42 views

Extract zip files into directory based on pattern of zip name

I have these zip files: PLP_633555_2015-03-04_01-12-01.zip PLP_634562_2004-03-02_02-15-07_UBIC.zip PLP_563462_2008-05-02_01-21-03_UBIC_STOC.zip And I need each zip extracted into its appropriate ...
4
votes
2answers
317 views

How do I print the (numerical) ASCII values of each character in a file?

How can I print the numerical ASCII values of each character in a text file. Like cat, but showing the ASCII values only... (hex or decimal is fine). Example output for a file containing the word ...
3
votes
2answers
156 views

Ctrl-Backspace and Ctrl-Delete in bash

Putting on Debian 8.3 stty werase '^H' or on Arch Linux 2/2016 stty werase '^?' in .bashrc (for example) makes Ctrl-Backspace delete the last word in the terminal. Still it's not the same ...
1
vote
2answers
759 views

bash scripting : using expect

I am facing an issue when I run simply these commands. The remote server want to pass "yes" to add the key in RSA file because first time connection established with scp. commands are given below ...
1
vote
3answers
49 views

bash is not terminating

I'm trying some things with my shell. This includes the following command: kill $$ My expectation was that the shell would log me out and terminate itself. But instead the bash persists without ...
0
votes
2answers
59 views

Credit card number validation with bash

I have used the following regular expression to detect the valid card numbers. [2-6][0-9]{3}([ -]?)[0-9]{4}([ -]?)[0-9]{4}([ -]?)[0-9]{3,4}([ -]?)[0-9]{0,3}[^a-zA-Z] But it does not detect the ...
4
votes
2answers
2k views

Convert mysql count(*) to int in bash?

I'd like to execute this and check if count is 0, 1 or > 1 in bash. mysql -e "select count(*) from mydb.mydb;" The output is: +----------+ | count(*) | +----------+ | 0 | +----------+ I ...
1
vote
3answers
67 views

Is there any way of speeding up this DNS script I made? [on hold]

Part of my work is doing a lot of different DNS lookups, so I created a script that displays the information that I need in a neat fashion. Problem is it's not very fast. Doing a bash -x I can see ...