Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

1
vote
1answer
28 views

How to update bash on Mac OS X Yosemite

Just trying to learn bash scripting a little. My old bash version: Bash version 3.2.53(1)-release... I've updated my bash on mac os x yosemite with homebrew: brew update brew install bash Then ...
1
vote
1answer
27 views

Bash script to execute jar with parameters and using file path variables

I am trying to run the following bash script and it gives me the following error #!/bin/bash -x jars= $HOME/SelGridProto/selserversidedjars java -jar $jars/selenium-server-standalone-2.44.0.jar ...
2
votes
1answer
29 views

Check for Free Space on Linux, email if critical

I just finished dealing with a server which had run out of space, and would like to setup monitoring on it now, to prevent it going critical in the future. What I would like is to get an email sent ...
3
votes
2answers
43 views

opening several terminals at once

In my dev environment, I sometimes need several terminals to be open, each running its own script/ a server (rails, django, redis, mongo, consoles, etc) How can I create some shortcut that will open ...
0
votes
1answer
17 views

Launch a bash sub-shell and expect a command

From a shell script, how can I launch a bash sub-shell for the user & wait for the user to type exit at the bash sub-shell prompt? I tried bash -c expect -c 'expect "exit" {send "Exiting\n"}'; ...
1
vote
2answers
17 views

Is there a way to pass arguments via pipe on bash?

Is there any way to pass arguments via pipe on bash? something like: echo value1 value2 | mkdir -p ./$1/$2 The line above would create the directories ./value1/value2 If this is not possible I ...
0
votes
1answer
13 views

Move spam emails from directory - bash script

I am trying to write bash script wich can cleanup my whoole server from spam emails that already are present in my client's folders. I would need this script to do, Check recursively directory ...
0
votes
1answer
18 views

Bash on android [closed]

I have a rooted sony z2 smartphone and I'm able to run sh scripts, I also have busybox installed but I'm unable to work out how to run bash scripts, I've tried ls -l /bin/bash from terminal and get ...
0
votes
1answer
21 views

Without eval command does not run correctly

just something that i can't seem to figure it out. Begginner bash scripter here I wrote a script to accept command line parameters that are later passed to maven Here's is the working version of the ...
0
votes
1answer
15 views

i need to pass a string of an output file to a variable so as i can use it globally all over my script [closed]

sample output RETENTION_INTERVAL ------------------ 10080 I need to pass the numeric value "10080" from the output file to a variable .The condition should validate value and ...
0
votes
0answers
5 views

avoid sigstop in script bash

alias notesave=' cwd=$(pwd) && cd ~/Desktop/Notes && git add * && git commit -a -q -m "-_\@" && git push -q origin master && echo "DONE!" && cd $cwd' ...
0
votes
0answers
19 views

Bash script monitor file modification after its closed

It has already been asked here and I have found the solution for the first part of my question. So for the moment I have a bash script (script1) where I evaluate the sha1sum of a specific file ...
0
votes
1answer
17 views

'hhighlighter' wrapper script saying command not found

I have gotten the wrapper script 'hhighlighter' from https://github.com/paoloantinori/hhighlighter which colors anything you want in stdout. I followed the instructions about installing ack-grep, ...
0
votes
1answer
19 views

Append text at the end of a specific line

I have a file with multiple lines. What I am trying to accomplish is add a string at the end of a commando. I have a script that installs a tool automatically. Now some things have changes in the ...
1
vote
1answer
41 views

Format terminal output to show apt-get upgrade errors in RED

I have a VERY simple bash script written for my Kali Linux distro so I don't have to run apt-get update, apt-get upgrade, apt-get dist-upgrade, apt-get autoclean, and apt-get autoremove every time I ...
2
votes
3answers
98 views

How to open one GNU screen tab for each directory in a list

I have the following script - it sort of works. #!/bin/bash ... define plugins, etc for plugin in ${plugins[@]}; do screen -t $plugin done Want I want it to do open gnu-screen and for ...
0
votes
0answers
32 views

Monitoring xinput keycodes in bash

So basically, what I'm trying to do is use the xinput command to watch for keyboard input in the background for a bash script to toggle things. I would like to ideally monitor multiple different ...
1
vote
1answer
35 views

Executing PHP file from command line with dynamic parameters

I need to run one script which will take one date as an argument. It is configured using cron to run on a daily basis, but I need to run it for a time range now. The issue is that this will fetch all ...
0
votes
2answers
41 views

Use “read” in Bash script with a standard answer

How can I use read with something as standard response, which the user can change though? (a default answer)
1
vote
1answer
9 views

Homebrew script to reinstall formulas

I'd like to develop a bash script to capture the currently installed Homebrew formula, then be able to reinstall these formulas in the event that I need to reinstall my OS. I'm hoping to combine ...
2
votes
1answer
22 views

Unset bash variables referring to non-existent directories

I have a file which is sourced by an application, adding relevant directories to $PATH and $LD_LIBRARY_PATH. This is fine, but it results in somewhat excessive pollution of the $PATH and ...
0
votes
1answer
50 views

Detect window's fullscreen status on Linux?

So basically, I'm trying to write a watchdog script, that checks window titles against a list stored in a file. If the window is fullscreen, the script should do nothing and move on. If the window is ...
0
votes
1answer
32 views

Passing different set of arguments to the different commands in a linux bash script

I am writing a bash script foo.sh that runs too commands bar with first input argument, and baz with the second argument: #! /bin/bash bar "$1" baz "$2" Now I want to make foo.sh more flexible, ...
0
votes
2answers
174 views

Update a sqlite database while select into a while loop

There is a bash script that will do "some magic"™ to files which will be referenced to a sqlite database and after doing "some magic"™ the database should be updated. Here are the simplified code ...
0
votes
1answer
29 views

Unexpected result from sort command of linux bash

I have a file foo.txt with this content: chr1 15 chr11 5 chr11 8 chr1 7 chr2 23 chr1 35 I tried to sort it first according to the first column, and then according to the second ...
2
votes
1answer
27 views

How to get status code of program piped to linux dialog command

I am trying to use Linux dialog to prepare simple installer for Ubuntu. The actual command is: dpkg -i package.deb 2>&1 | dialog --programbox "Installing..." 10 100 I want dialog to ...
1
vote
2answers
80 views

Restarting process in CentOS if server restarts

I have a VPS with some Java applications (made with "Play Framework") running on ports 9000, 9001, 9002 and 9003. VPS Provider (iPage) happens to reboot servers unexpectedly from time to time, leaving ...
0
votes
0answers
17 views

Is “Lynx: can't access startfile” normal when I'm looking for broken links? I'm kinda desperate

I'm doing a script in bash for checking broken links, is it normal that the dialogue "Lynx: Can't access startfile" appears when I run the script? This is my code so far: #!/bin/bash ...
0
votes
1answer
52 views

`if` statement with stdout && passing xargs through pipe

Say I have a list.txt of files I want to check. cat list.txt and for each file, I want to perform an action cat list.txt | xargs -I {} touch {} But depending on the outcome of the action, I want ...
0
votes
1answer
43 views

Does Killing A Bash Process Affect Children Processes [duplicate]

The Scenario I'm automating backups via a bash script. The script is executed via cron. The script archives directories recursively using tar, and then rsync's them to the remote host. Here is a ...
0
votes
2answers
27 views

Write PID To File On Bash Execution

I'm executing a bash script via cron. I want to write the process id (PID) of the script to a /tmp/ file for reference, in case I need to kill it later on (this script can take 6 - 10 hours to ...
2
votes
1answer
99 views

Unable to Create Files In Directory

There are lot of these kinds of questions on superuser, so I'll try and keep this quick by telling you what it's not: There is no application involved here. Just a user and a filesystem. I can login ...
2
votes
1answer
51 views

Creating directory name from file name - strip out non alpha numeric characters and make lower case

I am able to create a directory based on the name of a file. I am running into a wall if the text has spaces or non alpha numeric characters. I would like to strip out those non alpha numeric ...
1
vote
1answer
26 views

Get a range of lines from a file and replace a line in that range using awk or sed or both

I would like to replace a line in a section of the smb.conf file using either awk or sed or both if need be. Here's the section in the file... [CMI] oplocks = no wide links = no writeable ...
0
votes
0answers
34 views

Bash Script - Find “ERROR” and output to file

I'm writing my first bash script and could use some help / advice. I cannot test the script at the moment - just want to know if I have it setup correctly. I have a file $A_HOME/bin/nohup.out and I'm ...
0
votes
1answer
29 views

Bash read within a while loop issue

I'm trying to prompt the user to enter, say either "5" or "10" And then store it as a variable. And if they do not enter either of these two numbers, to keep prompting them until they do. I've tried ...
0
votes
0answers
53 views

Create a bash file in MAC OS to add static routes and dial PPTP VPN

Create a bash file in MAC OS, double clicking it would add a specific interface based static route in the routing table and then it dials a PPTP VPN.
1
vote
1answer
35 views

7z from bash script won't exclude directories

I've encountered with kinda strange behaviour of 7z (or bash, I don't know yet.). With the following script: #!/bin/bash find /home/user -type f -name "*.pdf" | cut -c 10- > ...
0
votes
1answer
152 views

How can I apply quotes to a URL in a .bat script?

The general form of a curl command in CMD that works is: curl -o latest.dump -L ...
0
votes
2answers
79 views

virtualbox increase cpu cores script wise

1x cpu core is not enough for an SMB filesharing Ubuntu box. How do we poweroff the VM at midnight, increase the cpu cores 1->2, and power on that box (script-wise)? (it's a windows host... but ...
0
votes
0answers
23 views

Security Monitoring Using last Command

I am new to linux administration and was looking for a good way to get e-mail alerts when a user logs in. I was thinking this might be useful as a security monitoring tool to allow me to see who is on ...
0
votes
1answer
39 views

Mass grabing part of HTML source code using shell scripts

From this page, a radio show http://www.ellinofreneianet.gr/sounds.php?s=0&p=10&o=l I want to download all the recorded shows. They are all this type of pages ...
0
votes
2answers
53 views

How do I concatenate strings from a list in a bash script?

As an example: List="A B C D" for I in $List do OUT=$OUT" -$I" done When I run this the result is: " -A -B -C -D" but want it to be: "-A -B -C -D" How do I concatenate without the ...
2
votes
4answers
170 views

Detecting known computer on public network in BASH

Anybody know of a way through BASH (specifically OSX terminal, but I'd prefer a BASH only solution without OSX' in built functionality) to detect a known computer on a public network (that I am also ...
2
votes
1answer
42 views

Surpress execution trace for echo command?

I'm running shell scripts from Jenkins, which kicks off shell scripts with the shebang options #!/bin/sh -ex. According to Bash Shebang for dummies?, -x, "causes the shell to print an execution ...
0
votes
0answers
44 views

OSX Convert and Network User to Mobile User or force all Network Users to Mobile

We have Macs that I am working on binding to LDAP (not AD) and I want to make sure when a user logs in using their ldap credentials that it either create them a Mobile Account or it runs a script to ...
-1
votes
1answer
165 views

Syntax error: “(” unexpected in bash script

The script is for adding torrent files to a folder and having them added to transmission. Here's the script: #!/bin/bash for file in /home/me/box/*/* do dir=$(basename $(dirname "$file")); sudo chmod ...
0
votes
0answers
18 views

Can I Query a Pdf Reader If It's On The Last Page?

I'm writing a wrapper shell-script to do the following: Searches a directory for .pdf/.djv files. makes an ordered "playlist" of files Opens 1st file in a pdf reader. Automatically change to the ...
3
votes
1answer
75 views

Bash: optionally passing arguments to a command

I'm trying to add arguments to a command call depend on another variable. Please look at the shell scripting code: curl \ $([ -z "${title}" ] || echo --data-urlencode title=${title}) \ ...
0
votes
4answers
74 views

Kill multiple processes by name instead of pid

I have a job that spins up 2-5 copies of a command on Ubuntu Server 14.04. I'm trying to figure out the simplest (i.e. single command-line instead of a script if possible) to kill all of them. The ...