Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

3
votes
2answers
1k views

How to get list of all child process spawned by a script

Context: Users provide me their custom scripts to run. These scripts can be of any sort like scripts to start multiple GUI programs, backend services. I have no control over how the scripts are ...
1
vote
2answers
31 views

Alternative to 'ls -A' in Bash

Is there an alternative to ls -A command in native bash functions? Wildcard * isn't the same. I tried hard to find one, but echo * doesn't show hidden files.
1
vote
2answers
39 views

Concatenate csv-files with the same name from subdirectories

I found some scripts concatenating text files from different subdirectories, but all of them produced output files like "output.txt", but didn't keep the original file name. Structure Folder_A ...
1
vote
2answers
28 views

how to gzip and scp at the same time

I have a file in which i wanted to zip up and at the same time transfer over to another host using scp. I tried to do the following command but failed. I do not mind zipping up and scp over later, ...
0
votes
0answers
18 views

Tar progress per file with pv for multiple files/folders at a time?

I've been using this one line command that I found on another post here and it works great for one folder at a time. This is the command: tar -cf - /opt/folder1 | pv -s $(du -sb /opt/folder1 | awk ...
1
vote
3answers
58 views

BASH: finding partition from diskutil output

I'm trying to search the output of a command listing local drives to find a partition called EFI on the boot HDD. I've written a really dirty oneliner as I can't seem to work out how to effectively ...
3
votes
2answers
219 views

How to properly restore settings when running a script using “source”?

I'm writing a script that needs to be executed using source, because its task is to modify the environment. During the script, I want to use set -e so that any error stops the script. The script looks ...
0
votes
2answers
20 views

Trunc xml file using unix shell script

I need to select particular set of tags which contains a particular value inside the tag. For example, below is the source.XML file <main tag> <subTag1>1298</subTag1> ...
0
votes
1answer
24 views

Pass a path with parenthesis and space in system call inside awk script

Inside my simple awk script, I call system command #!/bin/bash Test='/home/software/Other/new (Applet)' ls "${Test}" var=$(ls "${Test}") echo $var awk -vTest="$var" 'BEGIN { ...
4
votes
3answers
393 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 ...
1
vote
2answers
38 views

How to recursively create a hash file (sha512sum) inside each folder of a tree?

For a given tree, say /var/ftpd, how do I create a hash file in each folder of that tree with the contents of that folder within a given tree? sha1sum and sha512sum does not have recursion options. ...
2
votes
2answers
551 views

qsub -hold_jid -afterok loop not starting

I am trying to run a series of jobs submitted to the cluster, one after the other, by suplpying the following .sh script: Annotation_Loop.sh : #!/bin/bash job=`qsub run_IntersectBed_1.sh 0` for i ...
0
votes
1answer
37 views

BASH script that generates a header file with function prototypes

I am doing a C project which involves lots of static linking. To get rid of "implict function declaration" errors I will use a simple solution - a header file with function prototypes. I wrote this ...
0
votes
1answer
17 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
22 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": ...
0
votes
1answer
71 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
vote
1answer
46 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
votes
3answers
43 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 ...
0
votes
1answer
28 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?
-2
votes
2answers
3k views

Calculate % difference and file sizes between two files

We have two zip files and would like to compare them. We're also interested in calculating the percentage difference between them and the file size. Is there a tool that can do this quickly?
-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
32 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
43 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 ...
0
votes
1answer
53 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
42 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. ...
1
vote
3answers
535 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> ...
0
votes
1answer
63 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
40 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
57 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
40 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 ...
15
votes
2answers
20k views

How do I enter a literal tab character in a bash shell?

For example, I wanted to use the sort utility with the -t option to specify tab separators, but sort -t "\t" doesn't work.
1
vote
2answers
36 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
2answers
57 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 ...
0
votes
1answer
22 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
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
38 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
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
votes
1answer
27 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
60 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
37 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
1answer
75 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. ...
1
vote
0answers
35 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
53 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
22 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
81 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 ...
0
votes
1answer
340 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 ...
1
vote
2answers
70 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 ...
0
votes
2answers
20 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
1answer
100 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
0answers
23 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 ...