Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

0
votes
1answer
12 views

Variable as argument to Wine

The variable $INPUT_FILES in Case 1 has the same content (string) that is used in Case 2. Why in Case 1 I have problems with spaces in the name "2015 01 09.1.txt", but in Case 2 not? How can I fix ...
1
vote
1answer
15 views

Clear Bash quoting with JSON

I looked at similar questions before, but does not exactly answer my issue. I'm using cURL to send a JSON request, like this: curl -X POST -H "Content-Type:application/json" "$HOST" -d '{"uri": ...
-4
votes
0answers
42 views

How to convert a string to decimal values? [on hold]

I would like to convert word (i.e., a string) to decimal ASCII values, separated by dots, in bash. Example word: test123 Expected result: 116.101.115.116.49.50.51 This is what I have tried so ...
0
votes
1answer
51 views

Most favorite scripting language used by IT pros [closed]

What is the most favorite scripting languages used by IT pros and why? I see that Javascript is mostly used by developers while legacy VBScript and Powershell for Windows admins and bash/shell for ...
-1
votes
3answers
37 views

How to iterate through all the files/folders in a folder

I'm making a script to go through a folder renaming all the files and folders in it to VAR1, VAR2, VAR3, etc.. where VAR is a user specified variable. I wrongly assumed this would be simple. All I ...
-1
votes
2answers
31 views

Only show part of logfile in bash script

OpenVPN log looks like this: OpenVPN CLIENT LIST Updated,Sat Jun 20 04:20:07 2015 Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since [ A .... ] ROUTING TABLE Virtual Address,Common ...
0
votes
1answer
25 views

need to get average idle time using mpstat

I want to get average idle time of the server using mpstat. The problem I am having is %idle is not in same columns in all the versions of linux. example 1: [root@testserver ~]# mpstat 1 2 Linux ...
0
votes
3answers
30 views

Match the column heading and print the values of the column using awk

I have a data in the file in columns. I want to write a script, which displays the data of the column matching the column heading. C-1 C-2 C-3 C-4 C-5 C-6 C-7 C-8 C-9 10 30 35 20 9 65 87 30 ...
-4
votes
0answers
33 views

Rename files from 1.jpg to 001.jpg

I have several .jpg files named 1.jpg, 2.jpg, 3.jpg, ..., 21.jpg, 22.jpg, 100.jpg, 200,jpg I want to rename them to 001.jpg, 002.jpg, 003.jpg, ..., 021.jpg, 022.jpg, 100.jpg, 200,jpg Can ...
0
votes
1answer
36 views

In bash script, how to generate a random string

I need to generate many random alphanumeric strings, which also use capital letters. It needs to start with 3 characters (e.g. Dk6) and then, with a while loop, go up to about 9 characters (e.g. ...
4
votes
3answers
372 views

messaging.sh: line 29: [: missing `]'

I don't know if this is a bad thing, or what it means. My script still seems to work fine, but should I fix it? #!/bin/sh #This script will send text and maybe images to other computers via ssh and ...
0
votes
1answer
19 views

Sharing variables between applescript and bash script in same script

Is it possible, in a bash script, to have a variable, but also allow applescript (with osascript) to use that variable?
0
votes
1answer
49 views

Bash Script to generate <name> and pass this as command line argument to programm

I have an python script which gets 1 command line argument python arg Now I want a bash-script which: calls python arg & with the argument arg=000 make this x-times so therefore: python ...
0
votes
1answer
34 views

Remove last column values in field seperated file using unix shell script

The files is seperated by | pipe symbol myfile.txt Hello|how|are|you|hope|you|are|doing|fine Lilly|jasmine|rose|sunflower|nightfire|flowers I want to remove columns greater than 3. I want result ...
0
votes
1answer
33 views

SSH then running command in the same line is different to running on different lines? Bash Script

In a bash script, I'm trying to use ssh and osascript to display a notification on another mac. I can only manage to do this on the command line by first ssh-ing into the other mac then running ...
4
votes
3answers
53 views

Why some commands don't take input redirection?

For example, echo: [aesteban@localhost ~]$ cat tmp.txt Angel [aesteban@localhost ~]$ echo < tmp.txt [aesteban@localhost ~]$ As you can see, the output is just a blank line. According to my ...
0
votes
0answers
22 views

unexpected EOF while looking for matching `"'

JACOB=192.168.1.66 ZAC=192.168.1.65 echo "Type someone's name, or type ? to list options." read OPTNAME if [ $OPTNAME = "?" ]; then echo "Jacob's Computer: Type 'JACOB'" echo "Zac's ...
1
vote
2answers
30 views

Script answer to apt-get request “To continue type in the phrase 'Yes, do as I say!'” in bash

My script is replacing sysvinit with systemd inside a chroot while building a debian image with debootstrap. Since this is a "dangerous" action, apt-get will ask a silly question: "To continue type ...
0
votes
1answer
21 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
1
vote
1answer
30 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 running from the command line, the --persist option will force Octave to keep open after ...
1
vote
3answers
217 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
24 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
35 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
25 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
48 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
34 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
34 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
38 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
21 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
41 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
65 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
179 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
20 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
60 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
32 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
235 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
92 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
41 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
63 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
16 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
55 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
43 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
20 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
45 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
61 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
24 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
193 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
62 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
98 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 ...