Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

0
votes
1answer
23 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
16 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
27 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
17 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
33 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
6 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
36 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
34 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
22 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
87 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
35 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
22 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
23 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
23 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
32 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
28 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
63 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
51 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
22 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
35 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
31 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
115 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 ...
1
vote
1answer
24 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
20 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
88 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
66 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
58 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 ...
-1
votes
2answers
36 views

How can I modify the script to search for root directory for jpg files

I am using vi and I am want to modify my existing script in such a way that it searches for .jpg files in the root directory. #!/bin/bash DIR='/opt' find $DIR -name '*.gif'
0
votes
0answers
20 views

binary substitution in (audio)streams with bbe or sed

I try to do some stream manipulation with webradio streams. Goal is to use a pattern in triggerfile to substitute some seconds of the instream to silence in the outstream I found bbe to possibly fit ...
0
votes
0answers
7 views

Bash script query: what does NmaUtil::untaint do?

I'm trying to debug a script that uses expect to look at a remote servers disk space prior to transferring a backup file. The problem is that the remote server doesn't present the "Password" prompt at ...
0
votes
0answers
22 views

bash scripting with ssh

I am logging to a remote machine and doing some operation in a bash script. I used the following code but till chmod 777 $dbPath works and rest of the commands are not executed. ssh $node2user@$node2 ...
0
votes
1answer
50 views

output awk print to two separate files

Here is my current code md5sum filename.iso | awk '{print $1} {print $2}' This gives me two separate lines. The first line is the md5 of the file and the second line is the name of the file. I ...
0
votes
0answers
13 views

Search in multiple text files for lines that start With a string and show next a date (non determined) in ubuntu terminal

I'm looking for a date (not specified) with the format "DD-MM-YYYY" or "DD/MM/YYYY" that starts with at the beginning of the line with another string. inside some txt files, and assign it to a to ...
2
votes
1answer
44 views

Is this a bash-specific method of calling a script: VARIABLE=value bash somescript

I have worked all my life in HPUX/ksh shell, so bash these days seems to be throwing new ways of doing many things (many of which don't seem to be POSIX compliant - for example 'mkdir -p ...
0
votes
1answer
30 views

Repeat on user press, open up terminal, close terminal?

I am making a program and would like it to loop if an user presses a key. I also want to know if the bash file can automatically open a command terminal if it is not running from one to achieve the ...
0
votes
1answer
23 views

Print Windows mapping of root path in MSYS Bash

In MSYS Bash I get: $ cd ~ $ pwd /c/Users/antonio but: $ cd / $ pwd / Can I get the full Windows absolute path from Bash?
1
vote
1answer
54 views

Directory auto completion in bash scripts

Bash scripting newbie here writing my first script to copy a directory of pictures from one place to another. #!/bin/bash # Moves picture directories cp -R /path/to/pictures/$1 ...
3
votes
2answers
57 views

How to work around Bash for loop not exiting when a subcommand errors?

I have a for-loop in a shell script a la: #!/bin/bash set -u set -e for l in sh rb py php java cs; do (cd $l; ./run-tests.sh) done The intent is to have the for-loop die in a fire when any one of ...
0
votes
2answers
64 views

using 'case $1 in' to read command options- multiple flags after dash, and handling unusual flags?

I am making a bash script which uses both long options and short flags. Since I want long options, I can't use getopts. I tried using the following code: while test -n "$1"; do case "$1" in ...
0
votes
1answer
31 views

Script not working when run automatically

This script (parts of it) runs perfectly when invoked manually from the Terminal: #!/bin/bash [[ "`ps -e | grep -c $(basename $0)`" -gt "2" ]] && echo -e "`basename $0`: Mutiple instances ...
0
votes
1answer
29 views

Calling a list of functions provided on a stream

I'm writing a bash script to configure a server in which the end user will have to choose the actions to perform and the script will execute them. Each action will be implemented as a function. I've ...
0
votes
2answers
236 views

Getting errors trying to run shell script (Linux)

I'm trying to run the following script. I have run it before without issue, but now I encounter an error. #!/bin/bash # init function pause(){ read -p "$*" } echo & echo "(Website):" ...
0
votes
1answer
95 views

pass filename(with space in the path) as argumant to a wine app in a bash script

I want to luanch an wine App with passing a file as argument. I've two file, with the first I don't have any problem but when there is a space in the path wine can't handle the address properly. here ...
0
votes
1answer
51 views

Renaming files in a folder (and subfolders) by removing a token in filename

I have a huge amount of files in a folder (and subfolders) that I need to rename. For example, I have: movie1.mp4 fixed_movie1.mp4 ... What I need is to rename fixed_movie1.mp4 to movie1.mp4 ...
1
vote
1answer
48 views

How to make variables used in read global for the script

I want to read a file with the data ordered in column. In the script that I'm writing I use the read command. The input file is made by lines like the following: XX:XX:XX:XX:XX PQRTS ...
0
votes
1answer
20 views

Backing up github [closed]

I have a bunch of github directories and have been using a script with the "cp" command to backup to an external USB drive. I was wondering if I should be backing up directories that I make for ...
1
vote
2answers
924 views

Properly escaping forward slash in bash script for usage with sed

I'm trying to determine the size of the files that would be newly copied when syncing two folders by running rsync in dry mode and then summing up the sizes of the files listed in the output of rsync. ...
1
vote
1answer
106 views

Unable to delete a file using bash script

I'm having problems removing a file in a bash script. I saw the other post with the same problem but none of those solutions solved my problem. The bash script is an OP5 surveillance check and it ...
0
votes
1answer
225 views

Simple script run via cronjob doesn't work but works from shell

I am on shared hosting and I'm trying to schedule cronjob to run every now and then. Via cPanel I scheduled to execute my script but even though that according to my host support the cronjob runs, the ...