Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

0
votes
1answer
10 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

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
3 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
14 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
11 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
15 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
27 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
92 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
14 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
24 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
33 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
7 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
21 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
33 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
29 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
86 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
22 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
53 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
16 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
42 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
38 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
26 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
91 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
46 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
25 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
31 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
27 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
45 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
30 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
94 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
64 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
36 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
44 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
142 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
33 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
32 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
134 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
72 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
67 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
38 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
23 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
27 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
64 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
48 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
27 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?