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

learn more… | top users | synonyms

1
vote
1answer
23 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
25 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
17 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
23 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
31 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
53 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
29 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
13 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
24 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
27 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
34 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
82 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 ...
3
votes
2answers
101 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
71 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
17 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
21 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
15 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
21 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
844 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
26 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 ...
1
vote
1answer
29 views

How do I dynamically print explanations for the current options used in linux commands?

Is there a linux tool that upon for example when I run: ls -lrt will not only print the result but will also print ls - list files -l - show extended list -r - reverse -t - sort by time AND ONLY ...
-1
votes
1answer
54 views

How to move files from recursive hidden folder to the parent folder on OS X

I have a music directory 5 level deep, each folder have music and image files and also a hidden sub folder named .unwanted, I want to move the hidden files from folders named .unwanted, up one level ...
0
votes
0answers
39 views

Execute local commands from remote server using Xshell.

I usually use Xshell on windows to access my Linux server. Every time when I want to copy a PDF file from Linux, I need use sz file.pdf to copy the file, then locate and open the file on Windows. How ...
0
votes
2answers
29 views

script to accept aruguments and options smilarly lke commands

I want to write a bash script which works as command, it should accept both options as well as arguments without any options. I was able to write the script for accepting options using getops, but was ...
0
votes
1answer
48 views

Multiple Conditions in shell script

Im stuck in giving two conditions in my script. I can read two things - What is the NEAREST SERVER If it is MacBook or Anything Else and then use defaults write command to modify the plist file. ...
0
votes
1answer
7 views

Can you create mulitple groups at once in bash?

I'm trying to create multiple groups at once and give each one an ID. Can you do this without continually using the groupadd command? groupadd group1 groupadd group2 Thanks.
1
vote
1answer
43 views

redirection - why it doesn't work this way

I know there are 3 streams attached to a process when it is run namely the input, output and error stream. And redirection execution work from left to right. I intend to execute a command, redirect ...
2
votes
2answers
48 views

bash script.sh vs ./script.sh vs #shebang

Assuming i am in a bash shell now and i execute the following [me@server]$ bash script.sh q1) Is a new child bash process created to execute the script ? If i do a [me@server]$ ./script.sh q2) ...
2
votes
1answer
29 views

Dotfile version control: terminal settings

I use one MacBook at home and another at work. Recently I started version controlling my dotfiles. It works like a dream for my vim/MacVim settings, but is decidedly less useful for my .bashrc and ...
3
votes
5answers
156 views

bash keep variable reference in another variable

I have the following variables in my .bashrc: export UPRODUCT=productName export U=/path/to/products/$UPRODUCT So typing cd $U will take me to /path/to/products/productName. What I want to do is, ...
2
votes
2answers
35 views

Running bash scripts from bash script in other folder

I've got several folders (one for each month), each with a bash script savetodatabase.sh. I want to run all of them after each other, so I made a script named saveall.sh which has the following code: ...
0
votes
2answers
27 views

Trunc xml file using unix shell script

I need to select particular set of tags which contains a particular value inside the tag. For example, below is the source.XML file <main tag> <subTag1>1298</subTag1> ...
2
votes
2answers
49 views

. .bash_profile and . ./.bash_profile (./ and .)

I understand .bash_profile is a hidden file hence the period infront. I understand to execute a script under the current directory. You must specify ./, But I am not sure, why since we are already ...
1
vote
0answers
22 views

Make static site from wordpress site using bash

I have tried a few other scripts that can make a static version of a wordpress site but none of them are designed for bulk sites and I haven't found any that will just serve a static version while ...
0
votes
3answers
130 views

What is the config file for the sh shell on OS X? (i.e., ~/.bash_profile for bash shell, etc)

R uses the /bin/sh shell environment and I'm running scripts (that cannot be modified) that call gfortran-4.8 instead of gfortran so I'm creating an alias. I have added the following line to my ...
0
votes
2answers
92 views

How to open git for windows shell inside a tab on ConsoleZ

I have used git bash 1.9.5 from https://git-scm.com/download/win on ConsoleZ as shell and have no problem on open him inside a tab. But, with the new Git for windows 2.4.5.1 RC4, it open always in a ...
0
votes
0answers
36 views

Change bash to default login shell on AC66U running Merlin and Entware

I'm trying to switch from sh to bash as my default login shell, on an AC66U running the Merlin firmware. I have bash installed in entware's partition, but when I switch user:x:0:0:user:/root:/bin/sh ...
0
votes
1answer
45 views

BASH script that generates a header file with function prototypes

I am doing a C project which involves lots of static linking. To get rid of "implict function declaration" errors I will use a simple solution - a header file with function prototypes. I wrote this ...
1
vote
1answer
35 views

Redirections shell

Can anyone explain the following? :~$ ls macreave.sh fgvdvg > testo 2> testo :~$ cat testo macreave.sh ccess fgvdvg: No such file or directory :~$ ls macreave.sh fgvdvg > testo ...
1
vote
3answers
80 views

How to use grep or awk to save every line from text file as new file?

I am a scripting beginner. What i am trying to do. I have a text file that looks like this (example): hello hi there apple I am trying to make a script that saves every line as a separate new file ...
0
votes
0answers
12 views

Fail restore xampp backup

I'm trying to restore an old backup but I can not, I tried to make a new backup and restore but an error occurs. I tried the following commands all failed sh ./xampp... sh xampp... bash xampp.... ...
1
vote
0answers
14 views

MinGW Git Bash observable progress output inconsistency across machines

I am getting inconsistent behavior across installations of Git Bash on different Windows 7 machines. The diff in behavior is fairly minor, but I'd like to understand what could be responsible for the ...
0
votes
1answer
34 views

/bin/bash -c stopping counting with date

/bin/bash -c not starting counting with date: /bin/bash -c "while true; do echo [`date +'%F%t%T%t%Z'`] Keep Alive; sleep 1; done" The output is: [2015-07-06 13:44:36 UTC] Keep Alive [2015-07-06 ...
1
vote
1answer
25 views

Custom command not working

In my Ubuntu I tried to create a custom command: I added a bash script named ns3 in /usr/bin #!/bin/bash cd ns3/ns3-allinone-3.19/ns-3.19 I made it executable chmod +x ns3 Still it doesn't ...
0
votes
0answers
16 views

Bash filename tab completion when an environment variable is present

When I use tab completion on a normal path like this: vim /home/tester001/di<tab> it correctly expands to: vim /home/tester001/directory_1/ and I can continue like this: vim ...
0
votes
1answer
26 views

How to store data from different netcat connections in separate files?

I need a server that should receive data streams, store them in files and send further. Each connection should create a file with corresponding timestamp in file name, then write to it. My solution: ...
1
vote
2answers
33 views

How to get `make` to recognize alias command

I am installing MOOG, and when I make -f Makefile.maclap I get the error $ make -f Makefile.maclap g77 -w -c -o Abfind.o Abfind.f make: g77: No such file or directory make: *** [Abfind.o] Error 1 ...
0
votes
0answers
16 views

“fortune” command no output when running as daemon

I execute the fortune command from a daemon, but I don't get any output. If I run the bash-file from command-line I get the output without problems. echo "$(fortune)" The daemon is the Telegram-CLI ...
0
votes
1answer
37 views

Script to monitor realtime CPU & Bandwidth usage in xen live migration

I need to write a script (bash or python or ??) to perform live migration of a VM in xen, and to simultaneously log and extract the CPU & bandwidth usage of the Domain-0 AND write the output into ...