Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

0
votes
1answer
13 views

Zulu time format

I've a script which generates Zulu time zone. How do I change the format in shell /bash script like this ? 20140730000255 -> 2014-07-30 Thank you in advance Regards
0
votes
0answers
6 views

Show Octave plot from shell script

If I invoke Octave to plot something, it needs the interactive prompt to stay running and show the plot. When runnng from the command line, the --persist option will force Octave to keep open after ...
1
vote
2answers
69 views

Edit xml file using shell script / command

I need to do this using unix script or command There is a xml file in /home/user/app/xmlfiles like <book> <fiction type='a'> <author type=''></author> ...
1
vote
1answer
16 views

Bash script that should do stuff when the first command is CTRL+C-interrupted

I want to make a bash script to automatize a simple task. This task involves running a program (not made by me) which do something until user presses CTRL+C. After that, I have to process the output. ...
0
votes
2answers
29 views

Creating a bash routine

Everytime I log in into my work machine, I have to open a terminal and type the same routine: $ cd /Documents/some_folder/some_another_folder $ vagrant up $ vagrant ssh I'd like these commands to ...
-1
votes
1answer
21 views

This batch script does not echo out the value

I have a strange problem with Windows batch script. I don't understand where the error is, but what I can tell you is that, I did not put in mypersocom when asked to "Enter username :". It first ...
1
vote
3answers
35 views

list multiple file types in bash for loop

I wrote a script that converts images in a folder. The script uses a for loop: i="1" for file in *.jpg; do outputFile=$(echo "image"$(echo $i)) convert "$file" -resize 50x50 $outputFile ...
1
vote
1answer
17 views

tmux - get pwd of another pane in a bash script?

Is there anyway to find out information about the current working directory of any pane from within a tmux session? I'd like to write a bash script that changes the directory of the current pane to ...
1
vote
0answers
28 views

Linux: Finding Processes I Started To Kill Them

I am programmatically starting several servers in Gnome terminal with each server in its own titled tab: gnome-terminal \ --tab -t "Server1" -e 'bash -c "export ...
0
votes
1answer
27 views

Linux Bash Script File Search for Log File

How would I go about writing a Linux bash script for the following? I need to search for a file of format [unique_number].log This file would exist within one of the following directories ...
-1
votes
1answer
15 views

Cygwin Bash Script?

I have no real clue about linux, but need a simple script to copy what I manually do 1. Open Cygwin 2. Type a directory name (micros) 3. Type a command (reload) That's it...I just can't get it to ...
1
vote
2answers
34 views

How to use github via HTTPS?

I'm trying with this to create a simple static HTML website using github. I already created a repository named: "GITHUBUSERNAMEANDREPO". #!/bin/bash git config --global user.name ...
1
vote
1answer
46 views

bash behavior on sigterm

Have a script as below: #!/bin/bash # # run this script. don't run it if it's already running. # PIDFILE=/tmp/script.pid LOGFILE=script.log if [[ -f $PIDFILE ]]; then echo "$PIDFILE exists. ...
0
votes
1answer
54 views

“Failed to start SYSV” when starting self-made service

I'm trying to set up a service, on root, that will automatically start monetdb database after system startup because monetdb doesn't provide such mechanism. I've created /etc/init.d/monetdb script ...
0
votes
2answers
17 views

Using MV to rename large amount of files using a script

I'm writing a bash-script to rename a large amount of files, using mv. Original filename File001.txt New filename file-new-001.doc I can change the suffix but i do not know, how to insert the ...
0
votes
0answers
17 views

Remove orphaned data without corresponding torrents in the rtorrent's list

I use rtorrent with a plenty of frontends like ruTorrent and Transdroid. Often, when I try to delete both the torrent and data through these frontends, the torrent is removed from the list but the ...
1
vote
2answers
44 views

Given key-value content, how do I group values by key and sort by value?

I've the following sample input format (file or stdin): key1: 1 key2: 2 key3: 3 key1: 4 key2: 5 key3: 6 Is there any few-liner which can group values based on the key and then sort? Expected ...
2
votes
2answers
28 views

GNU sort cyrillic lines ignoring the case

I have got a file in UTF-8 with lines of latin or cyrillic letters. I'm trying to sort it, ignoring the case. I have tried LC_ALL="ru" sort --ignore-case in.txt but still got cyrillic lines in ...
2
votes
1answer
171 views

How to make a bash script that names files with today's date

I'm trying to make a script to back up my we servers, but I have very limited knowledge with bash scripting. I want the script to name the backup file ht-"today's date". How would I go about doing ...
0
votes
4answers
77 views

While loop Bash script that outputs how many users use a certain shell

So I am stuck on trying to create a bash script while loop function that takes the input from /etc/passwd and outputs how many of users use bash, nolongin, csh, and ksh. I believe I am supposed to ...
0
votes
2answers
28 views

Unix/linux shell scripting floating point division

I have to divide two floating point values and store it in variable. My code below v_missedvol=4003.03 v_allvolume=3003.03 v_vol_temp= $(echo "$v_missedvol / $v_allvolume" | bc -l ) the result ...
1
vote
2answers
53 views

How to redirect output to file that has slash in name

I want to create a file named ./https://www.example.com, but the following doesn't work: [ ~]$ URL="https://www.example.com" [ ~]$ echo "Hello!" >"$URL" bash: https://www.example.com: No such file ...
1
vote
1answer
14 views

Cut lies if delimeter doesn’t exist

For example: $ cut -d ' ' -f 2- <<< "example" example Why does cut lie to me telling me that “example” is the second delimeter and on. I want it to print "" since there is no second ...
1
vote
1answer
41 views

How to daemonize a bash script only if --daemon flag is given?

I have my script.sh and want to run it with ./script.sh or ./script.sh --daemon, having it remain in the foreground unless the --daemon flag is given, in which case it should detach and go into the ...
0
votes
2answers
30 views

Forcing a process to background from bash script

I'm trying to crfeate a bash script that - amongst other things starts sunwait: /root/bin/sunwait sun up -0:00:00 54.453158N 11.013071E; mycommand & Sunwait is a binary that will wait for ...
0
votes
1answer
18 views

Dealing with a string as file input for a program within bash script

Say I have tool X that accepts only files as input, is there any way to pass input to X as a string without having to write it to file then reading it within a bash script?
0
votes
3answers
40 views

Is there an automatic way to add group read permissions to “nohup.out” when “nohup” is run?

I run my Java code from bash script using a command like this: exec nohup "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" com.myClass "$@" & Which creates the output file nohup.out and this ...
1
vote
3answers
48 views

Looping until background process is done (with `jobs`) doesn't work in script

I'm trying to loop until a background process (launched earlier in the script) is complete. An easily reproducible test case is: ping -c 10 localhost &>/dev/null & On the command line, I ...
0
votes
0answers
20 views

shell script to generate a log file for VM Backups

we are using PHD virtual backup to trigger backups for VMs and now i want to generate a report of all VMs in a file consisting of VM Name, Date and Backup Time and mail it to my ID at particular ...
0
votes
1answer
130 views

Why am i getting execute binary file error?

i am getting following email every 10 min. as I own the VPS. I am not expert in linux and am learning to manage linux servers. Please help me why am i getting these emails and how to stop them or how ...
1
vote
1answer
56 views

Bash: better way to output to both console and output file than tee?

What I need to display is a log refreshing periodically. It's a block of about 10 lines of text. I'm using |tee and it works right now. However, the performance is less satisfying. It waits a while ...
0
votes
1answer
60 views

How to execute multi-line ssh command stored in a variable

Context: I'm trying to execute a bunch of commands on a remote machine that I cannot access directly - I first have to ssh into a gateway machine, then ssh from there and run the commands. Basically ...
0
votes
0answers
45 views

+Merlin FW / Port Forward via IPtables?

I have 2 WiFi Thermostats, Heatmiser, that i can control remotely, from LAN without issues, but only one from WAN. The thermo have a fixed port that cannot be changed and there is an App thet can be ...
0
votes
1answer
32 views

$RANDOM in script vs. on command line

I think I found a really odd bug in Bash's random number generator ($RANDOM). Showing is easier than telling, so here's what happens: The goal is to get random digits. If I execute this, I get 20 ...
0
votes
0answers
26 views

Having trouble building Vagrant bash script

I'm trying to set up a bash script provision to help build my virtual machine with Vagrant, but I'm clearly doing something wrong. Unfortunately the Vagrant docs don't provide any examples more ...
-1
votes
2answers
50 views

simple loop not working

A simple script now="$(date +'%d_%m_%Y')" path="/var/www/vitalii/backups" sites=("site1.ru site2.ru site3.ru") for i in ${sites[*]} do echo "$path/$i" #tar -cvzf $path/$i_${now}.tgz ...
0
votes
0answers
28 views

Spawn new consoles from script and get back to the main console instance

The goal is to use a script to launch and execute a command in n separate window terminal: (I use lxterminal) It works when I copy/pase the following block of commands, It executes each lines ...
0
votes
0answers
78 views

how to grep exact pattern

I’ve tried several grep / egrep ideas with different options but none worked here. I’m trying to grep exact match of the pattern I’m looking in a log. For example I want only a pattern “ERROR” to get ...
0
votes
0answers
13 views

Curl should be quit but it returns ever something

I tried to login to a website using curl in a bash-script. It is possible to login to the site quiently using this: curl -d "username=$username&passwd=$passwd" -c $cookiefile ...
1
vote
0answers
17 views

Grep from Log & Calculate then alert

I have a log file, which has the below lines in it. I need a bash script, which takes the values in Bold (4092.1M / 20.1G) & do the math & then alert from Zabbix [Eden: ...
0
votes
1answer
174 views

Require bash script to be run with sudo (not as root user)?

I want to require a bash script to be run as the current user with sudo, but prevent it from being run if it was executed as the root user directly. This is because I'm doing some setup actions for ...
1
vote
1answer
91 views

[: -gt: unary operator expected

I have a code, which gives [: -gt: unary operator expected, when the value is empty. Can anyone please suggest or correct me where I'm wrong ? if [ -e $POSFile ]; then # Read last Position ...
0
votes
1answer
44 views

BASH associative array rearrange keys

I am running into a weird issue with associative arrays in bash. I have the following files in a directory: ls -lart drwxr-xr-x. 3 root root 4096 Feb 9 11:14 .. -rw-r--r-- 1 root root 3275 Feb 9 ...
0
votes
1answer
24 views

How to detect ips using nmap?

I am currently working on demonstrating Man in middle Attack foe which I am using my phone as a Victim and my PC running ubuntu 14.04LTS as attacker. I am using nmap to ping my phone to check if its ...
12
votes
2answers
480 views

Difference when using backticks in double quotes and single quotes in Bash

Why to the following two executions differ in output? (I need double quotes for variables in my eventual command) $ sudo su -c "echo `cat /root/root_file`" cat: /root/root_file: Permission denied $ ...
0
votes
1answer
73 views

Bash function only works when password manually input

At work I have to run the following function everyday. The function works fine when I am prompted for the password. However, I tried to hardcode my password so that I don't have to enter it in each ...
0
votes
4answers
115 views

How do I DELETE a comma and a space from a numeric string using a bash script

Folks, I have asked this question 5 times on here and have received 5 separate bits of code from super users that have all *failed. Problem: I have stock information being brought back into a txt ...
0
votes
1answer
34 views

Bash script failure

I have this script. It works fine on one of system but it's giving some error on another machine: 1 #!/bin/bash 2 EXEC_DIR=`dirname ${0}` 3 source ${EXEC_DIR}/config.sh 4 5 ...
0
votes
1answer
46 views

I want to append the name of the file on the top of that file using bash script

I want to add void mainfunction() on the top of a file. I am reading the actual name of the file from another file and the name of the main function from another file. I was using: sed -i 1i void ...
1
vote
1answer
89 views

Bash loop through all directories within a directory and if find any instance of string in each directories specific file do this

I have a service that utilizes a unique user specified port for remote connections. I install multiple instances of this service and wrote a bash script to automate the installs. My installer has a ...