Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

0
votes
0answers
16 views

custom dotfiles sourcing ~/.bash_profile

I am trying to create my own dot files. In the root folder I have an installation script. I am watching other repositories like Lars Kappert to create this. I am using oh-my-zsh. I created the ...
3
votes
1answer
16 views

splitting separate bashrcs for different purposes

I was wondering if I can split my .bashrc into separate parts, and linux will pick up both files and use them correctly. I have general purpose scripts like 'cleanproject', and scripts that are only ...
0
votes
2answers
42 views

How to insert lines into specific files in which a string is not present?

I'm looking for some help with a small script. I would like to search all files corresponding to /usr/local/directadmin/data/users/*/httpd.conf for the string centralized.log If the string is ...
1
vote
3answers
38 views

Determine Partition OS

Is anyone aware of a way to determine the OS installed on a separate unmounted partition without mounting it in Linux? I'm trying to determine which has Windows installed with a script while live ...
0
votes
1answer
25 views

Alias that runs a sub command

I want to run 2 commands under an alias, but since it includes cd and I don't want to change folder from the main caller, I thought it may help calling a subcommand: alias lhu="$(cd /my/path ...
1
vote
2answers
44 views

escaping awk with remote ssh command and bash that is already escaped

Hello. ssh ufk@10.0.0.2 "bash -lc 'pm2 list | grep app | awk { print $3} '" I need to run the command I pasted here. the problem is that i'm already escaping twice... the bash with " and the pm2 ...
0
votes
1answer
44 views

How can I rename all image files within a directory (and recursively within its subdirectories)?

I have a directory containing a large number of image files, some of which are in subdirectories. I need to rename all image files matching *.png, *.jpg, *.jpeg, *.bmp, *.gif using a simple pattern ...
1
vote
2answers
56 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.
0
votes
0answers
22 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
2answers
54 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
35 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, ...
1
vote
3answers
69 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 ...
0
votes
1answer
29 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 { ...
1
vote
2answers
66 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. ...
0
votes
2answers
26 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
43 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
23 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
25 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
90 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
46 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
32 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
45 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
79 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
51 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
416 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
35 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
62 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
115 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
58 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
72 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
48 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
25 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
60 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
892 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
40 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
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
93 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
50 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
36 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
61 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
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
87 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
505 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
21 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
33 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
98 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
38 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 ...