Bash is a free shell for Unix-like operating systems from the GNU Project.

learn more… | top users | synonyms

0
votes
1answer
19 views

bash - processing output one line at a time

I read that xargs was good for processing the output of a command one line at a time (and it is). I have the following line in my script. ./gen-data | awk '{printf $2 " "; printf $1=$2=$3=""; gsub (" ...
1
vote
2answers
16 views

how to gzip and scp at the same time

I have a file in which i wanted to zip up and at the same time transfer over to another host using scp. I tried to do the following command but failed. I do not mind zipping up and scp over later, ...
1
vote
1answer
17 views

bash: Different results if same function is called from sourced script or executed directly

I've run into a something that I don't understand, and I've managed to reproduce the situtation in the script below. If I source the script it fails with head: 1: invalid number of lines. But if the ...
1
vote
0answers
19 views

Custom script in /etc/rc.local - not starting X properly

I made a script called starter.sh: #!/bin/bash while true; do sudo fluxbox & sudo -u pi epiphany-browser -a --profile ~/.config http://localhost/index.php & sleep 2s done; Which is ...
-1
votes
1answer
15 views

Trouble setting up the class path for MySQL and running MySQL via terminal

Question: what is the easiest way to run the MySQL app from the terminal What I have tried: Using some stackOverFlow suggestions I have used the following commands echo $PATH, produces ...
0
votes
1answer
16 views

How to use echo in shell command from Makefile?

I have a GNU makefile. It runs fine on Linux, Solaris and OS X. However, under Cygwin-32, Cygwin-64 and MinGW, it produces: /bin/sh: -c: line 0: syntax error near unexpected token `(' /bin/sh: -c: ...
2
votes
5answers
67 views

Any way to avoid dot-slash when running executable scripts in bash?

let's say I have a script. chmod +x myscript Now to run this I go ./myscript But is there any way I could just run it by typing myscript ???
0
votes
1answer
22 views

alias disables colour sustainably in bash

When I do tree -N I get nice coloured output. When I then alias tree="tree -N" tree output is black & white. When I then unalias tree tree -N output is still black & white! GNU ...
0
votes
2answers
35 views

How to store formed command line without running it in bash or terminal?

For example, I have formed a long complicated command that will improve the world and lower an entropy in the Universe. But then (huh!) I see that I forgot to make a dir required. I want to store my ...
0
votes
0answers
19 views

bashrc file read error in xterm

My bashrc files is read but is not interpreted correctly. qwul@qwul-ThinkPad-L440:~$ cat .bashrc #PS1='\[\e[1;32m\]\][\W]\$\[\[\e[0m\]\]\] ' alias la="ls -a" #alias ll="ls -l" ...
0
votes
1answer
25 views

bash error when starting shell from tmux

When I open a new shell in tmux I get an error message. This error message does not show up when I start a new shell in GNOME terminal. What might tmux be running at startup that I need to check? ...
0
votes
1answer
18 views

Extract each digit of variable and store as new variable in bash

I have a variable that is a number ranging from 1 - infinity. Lets say the number is 40. I need to store 4 as a variable, and 0 as a variable. Since the number can grow beyond 2 digits, lets say the ...
1
vote
1answer
28 views

parsing condensed options to bash

I have something like this: while [[ $# > 0 ]] ; do key="$1" count=0 echo "$1" case "$key" in -r|--rotate) shift rotate $1 shift ...
1
vote
1answer
65 views

SSH Bash script for repeated commands on a network cluster

I have a network cluster of about 100 machines, a piece of software and a large list of different parameters for the software. I want to use the cluster to speed up the calculation, so each machine ...
1
vote
3answers
53 views

BASH: finding partition from diskutil output

I'm trying to search the output of a command listing local drives to find a partition called EFI on the boot HDD. I've written a really dirty oneliner as I can't seem to work out how to effectively ...
0
votes
0answers
30 views

Backup script to online backup - Pseudocode look over

I just want to pitch an idea here, before I start writing the code. I thought I build it in bash. I am not very proficient in writing scripts, but I had a few successes and this could be good training ...
0
votes
2answers
42 views

How to tell what are my startup files for sh or bash?

From this question I understand that depending on the operating system sh and bash behave differently. Doing env and alias I can tell that: Every time I open a OSX Terminal or run bash the variable ...
0
votes
0answers
52 views

bash script how to change date with hrs format and add missing days with copy of above line [migrated]

I have csv file with data: "smth","txt","33","01-06-2015 00:00" "smth","txt","33","02-06-2015 09:06" "smth","txt","34","03-06-2015 09:54" "smth","txt","34","04-06-2015 00:09" ...
1
vote
1answer
26 views

How to use unlimited list of arguments to a command in bash shell?

I'm running up against the "argument list too long" problem using a command in the shell (bash in my case). Most suggestions for working around this suggest using find or some variation, presuming ...
0
votes
0answers
33 views

Changing the HOME for Cygwin

I'm trying to change the home directory for Cygwin on a computer at work. Our home directories mapped to a network share by default. This seems to cause some confusion for Cygwin, as it created a ...
0
votes
1answer
23 views

Particular bash bc usage not storing result in variable

Unfortunately this result in a empty variable, and bc command print its result to terminal anyway while trying to attribute to aux aux=&(bc -l <<< "scale = 5; ...
1
vote
0answers
32 views

Shell Commands not working : REDHAT

I added some service to the startup script and then after reboot , i got this message- 24 package(s) needed for security, out of 52 available Run "sudo yum update" to apply all updates. -bash: id: ...
2
votes
1answer
45 views

Execute command after broken SSH connection

Is there a way to execute a command after an SSH connection is broken (blackout etc.)? When I normally log off I can just use .bash_logout but I don't know what to do when my connection breaks.
0
votes
1answer
22 views

Why does my vim colorscheme stay after I close vim?

I recently used vundle to install the solarized theme for vim on my Arch Linux machine. Whenever I open vim, the theme is applied, but it stays applied to my terminal window after I close it. I can ...
0
votes
1answer
22 views

OS maintenance scripts: bash or Python? [closed]

I'm creating more and more OS maintenance tasks across half a dozen computers I have. These are mainly OS X and Linux systems. The tasks are simple enough things like backups, permissions ...
0
votes
1answer
31 views

Error while trying to execute cron script with space in path

I have a script with several rsync commands in it. The script file is placed in an NTFS partition with owner and group permissions set to root. I have no problems running the file manually from the ...
1
vote
2answers
32 views

Is there a way to make my .bash_profile load the contents of my .profile file?

I was using a .profile quite happily for two years on my Mac now running Yosemite. A recent brew install created a .bash_profile and whilst my .profile still exists, it is now no longer loaded. I ...
0
votes
1answer
37 views

Changed cygwin home location, now the terminal can't find my .minttyrc config file

I had to change the HOME location for Cygwin by setting it to pick up the directory I set in /etc/passwd (following the solution from here). It seems to not be a problem for the majority of my ...
0
votes
2answers
27 views

How do I get a bash script to echo itself into a new file?

I have a bash script. I want to have this script recreate itself in /usr/local/bin without needing an additional file to do this. bash_a.sh: ssh -t -t server-a.com " cd /var/ irb ..etc " I was ...
1
vote
1answer
15 views

bash: history -a not writing unless HISTFILE already has text

Problem statement I've been following numerous examples for doing creative things with bash history along the lines of: # simplified example PROMPT_COMMAND='history -a; history -c; history -r' ... ...
0
votes
1answer
19 views

Why does this bash file stop my tomcat if the session closes?

The following bash script starts an Apache Tomcat and tails the log file to the screen: #!/bin/bash ~/tomcats/TC1_8083/bin/startup.sh tail -f ~/tomcats/TC1_8083/logs/catalina.out If I CTRL-C the ...
1
vote
1answer
15 views

Using strace, how do I use it to get the network and serial calls

I have a python program that runs in the background, what I need to know for debugging purposing is that I need to see what calls it is send and receiving for serial, network and to stdout. I know ...
0
votes
1answer
19 views

Double SSH and execute interactive shell

I need a bash script to ssh into server a then server b then execute an interactive shell. This is what I have: ssh -t -t server-a.com exec "ssh -t -t server-b.com <<<EOF cd ...
1
vote
1answer
23 views

Remove invalid domain names with Sed

I'm having trouble writing a sed command do the following. I have a file that should only contain "valid" domain names. How I use with sed to remove any line that does not match an expression? The ...
2
votes
1answer
35 views

How do I determine the PID of my python program if there is more then one python program running?

I have two python programs running on my system, say they are called program x and program y. I want to get the pid of program y, but not x for my bash script. When using pgrep python, I get the pid ...
0
votes
1answer
23 views

Cannot exit normally when ssh'ing using bash script

I have a script that ssh into a server and sets up an environment ssh -t -t dev.example.com <<EOF cd var/dev/ ...other commands... EOF But when I type exit in the terminal after the script ...
0
votes
1answer
11 views

Weird result of initiating a variable with the output of 'git describe'

For some reason this assignment: OUT=$(git describe HEAD) prints to the stdout (for example): fatal: No names found, cannot describe anything. Is this a normal behavior? Why doesn't this happen with ...
0
votes
3answers
21 views

How can I get the permissions of a file in octal format?

... and how can I set them? Does this work for directories in the same way? What happens with sticky bit and that more "exotic" stuff?
0
votes
1answer
23 views

What is the best / common practice to include a function that is used from several scripts?

I currently did this by sourcing a functions file including all my functions into the several scripts that use it: source ./functions.sh One disadvantage I noticed is that the line number bash ...
1
vote
2answers
34 views

How can I find out the number of arguments that are actually passed to a bash function?

Given a bash function: function f1 { echo "The function f1 is being called with ??? argument(s)." } and two invocations: f1 arg1 f1 arg1 arg2 How can I get the number of arguments passed? ...
0
votes
0answers
23 views

Running 'su - user sh -c “~/.profile”' returns “No such file” error

I have a shell script running as root with the following command: ssh remotehost 'su - user sh -c "source /home/user/.profile; <command>"' I get the following output: bash: su - user sh -c ...
0
votes
3answers
46 views

How to manually send an ARP request

I recently sniffed with Tcpdump a packet "ARP, Request who-has 192.168.2.3 tell 192.168.2.2, length 28". I would like to reproduce this message, and to send an ARP request from my laptop to any IP I ...
2
votes
2answers
46 views

How to change the default shell in Cygwin?

I am trying to change my default shell from bash to zsh in cygwin. The normal unix command chsh isn't available on cygwin The etc/passwd file it seems isn't used anymore in existing versions of ...
1
vote
4answers
38 views

How to disable set -e for an individual command?

The set -e command makes a bash script fail immediately when any command returns an non-zero exit code. Is there an easy and elegant way to disable this behaviour for an individual command within a ...
3
votes
0answers
12 views

GNU screen is slow exiting

I've set up my .bashrc to automatically screen -DRA (even though it's a local session). screen works fine, except that if I run exit from the last window or otherwise close it from the client itself, ...
0
votes
0answers
16 views

using FISH shell — set default folder for multiple tabs?

I'm using fish shell in OS X. Using the standard bash shell, you can open multiple tabs in Terminal, cd to a different directory in each, and then save the setup as a Window Group (via Window > ...
1
vote
1answer
14 views

chmod without modding other user perms

I want to chmod a file but I want to do it so it doesn't effect the other "user"/"groups" e.g. giving the root 0 before 741 chmod 0** [filename] after 041 or give the group a 7 before 741 chmod ...
0
votes
1answer
16 views

expr bash command returning 0 in substring evaluation

What I'm trying to do is read a line from a file, store it in a variable $line and extract all instances of (that is, angle brackets with only uppercase letters between them). What I'm trying is: ...
10
votes
4answers
821 views

Pass text to program expecting a file

Related to a question I asked on Stack Overflow: Passing multiple lines of code to wsadmin.sh?. I have, as a string, a few lines of input that I need to feed into a command. The command, however, ...
1
vote
1answer
22 views

How to get notified when a specific file is deleted in Linux?

I'm looking for a way to monitor a file and trigger an event as soon the file was removed. Once it is removed I will replace/copy a new file and start the monitor again. E.g. watch ...