Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

0
votes
1answer
40 views

Bash provide options and pass variable on choice

Trying to give an option to users of an installer to chose either "Development" or "Stable". By default the installer does "git checkout 1.1.0", but I'm turning 1.1.0 into $GIT_VERSION and trying to ...
1
vote
1answer
44 views

bin/bash script: toggle bluetooth state?

I'm trying to do an alfred workflow that toggles my bluetooth connection. STATUS=$(/usr/local/bin/blueutil status) if [ $STATUS == "on" ] then /usr/local/bin/blueutil off echo "off" else ...
1
vote
2answers
460 views

How do I get Linux commands and scripts to work on Cygwin?

I'm back with a follow up question. How do I get Linux commands to work on Cygwin? First I asked you what tool should I use to help me run my Linux scripts on Windows and you suggested Cygwin and I ...
0
votes
1answer
142 views

How do I run multiple scripts within a script, even if one script fails

I have a simple bash script that executes a number of other scripts … #/bin/bash … ./update_artifact1.sh $ARTIFACT_VERSION ./update_artifact2.sh $ARTIFACT_VERSION ./update_artifact3.sh ...
2
votes
2answers
100 views

How can sed find pattern in one field but append another(same row)

I have a text file that has comma separated values. Field1 has field that needs to be matched, but field two needs substitution based on the match. Example: A,C B,C Result: A,D B,C I'm guessing ...
0
votes
3answers
233 views

how can sed get patterns from a file

I have two files one holds a list of patterns, another need to be changed based on these patterns. So far I have been experimenting with cat patterns.txt| xargs -n1| sed ...
0
votes
0answers
84 views

automate drive mounting after Cisco AnyConnect client is connected

I have a request to write a bash script for clients to open VPN connection and automount remote drives. I am not sure how to approach it. I figured out I can use "vpncli.exe connect " to connect, but ...
0
votes
0answers
123 views

find files between dates and move to other directory

I have multiple logs file in one of the direcortories, was trying to move them monthly wise to another path. tried below script for the same. for Month in `seq -w 1 12`; do MLDAY=$(date -d ...
-1
votes
2answers
84 views

Execute a command for 3 lines at a time

I'm trying to run three separate processed while reading foo.txt Here is the example: cat foo.txt | while read line do echo line1 echo line2 echo line3 echo "" done The expected output is: line1 ...
8
votes
1answer
579 views

why doesn't a bash while loop exit when piping to terminated subcommand?

Why doesn't the command below exit? Rather than exit, the loop runs indefinitely. While I discovered this behavior using a more complex setup, the simplest form of the command reduces to the ...
0
votes
3answers
49 views

Newline in a for loop

How can i make a newline in a for loop in bash? I've tried echo -e but its not working. When i am opening a log file everything is on a single line. for i in */ ; do ...
0
votes
2answers
600 views

Bash tar and output to log file

How can i write TAR operation in to a log file? tar -czvf arh.tar.gz public_html > 1.log TAR -czvf worked thanks guys! Now in bash script: for i in */ ; do ...
1
vote
0answers
117 views

Rsync do not do anything if files not changed

#!/bin/sh date=`date "+%Y-%m-%dT%H:%M:%S"` rsync -aP --link-dest=/target/current '/source/folder' /target/back-$date rm -f /target/Backups/current ln -s back-$date /target/current This is a little ...
0
votes
1answer
165 views

bash script to tar multiple domain folders

!/bin/bash sitedir="$HOME/domains" logs="$HOME/site_backups/log" tbackups="$HOME/site_backups/today" ybackups="$HOME/site_backups/yesterday" echo "`date`" > $logs/backups.log for i in `ls`; do ...
0
votes
1answer
105 views

Simple bash gpg update script

I have a text file in which I save all my important personal data like all my accounts' passwords and my credit cards' PINs in case I forget those. Obviously, that file needs to be encrypted, so I ...
-1
votes
2answers
114 views

zip subtitle files recursively on linux

I got 2 main folders Peliculas and Series, as you may guess Peliculas has movies on it (some of them on their own folder, the ones that have more than 1 file) and the folder Series has tv shows. What ...
0
votes
3answers
113 views

“cp --parents” equivalent on Mac

The topic explains it -- basically I have a bash script used on a Linux system and a Windows system with Cygwin where the following command works perfectly: cp --parents However, running this same ...
0
votes
0answers
46 views

Rsync delete issue

I implemented rsync to backup the data from the server to my local machine,and done it regularly by cron. It works fine but yesterday it deletes the files from the folders on my local machine but on ...
-1
votes
1answer
19 views

How to create a command line tool to set up web projects?

I am web developer, and everytime I start a new project, I have to set up my folder structure and starter files by hand. Is it possible to write a small command line tool (Bash) that does this for me? ...
1
vote
1answer
436 views

extract characters between first and second underscores of filenames and count such files in linux folder

I would like to extract characters between first and second underscores of filenames in a folder and count such type of files present in it. The folder contains files in a particular format such as : ...
1
vote
2answers
804 views

Apple Mavericks - why doesn't this one-line BASH script set my Python virtual environment like I expect?

I have the following Bash script: #!/bin/bash echo $MYPROJECT_HOME/bin/myproject_venv/bin/activate source $MYPROJECT_HOME/bin/myproject_venv/bin/activate echo ...
2
votes
2answers
96 views

Delete files and exclude some with find [duplicate]

It was an old problem. I knew how to delete files and exclude some, like this: rm `find ~/temporary/Test\ 1 -mindepth 1 -maxdepth 1|grep -v 'A'` but the problem is the folder 'Test 1' containing a ...
0
votes
1answer
530 views

Problems using EXPECT is a BASH shell script

This is the code (bash script): echo "Pass for router:" read -s pass /usr/bin/expect <<EOD spawn ssh 192.168.10.1 -l root 'opkg list-installed' > list-installed.txt #echo @pass expect ...
0
votes
1answer
444 views

Bash script to pull from master every morning

I'm trying to automate my workplace as much as I can, but I'm kind of new to bash scripts. What is the best way to tell bash script to run git co master and if it is successful do git pull and once it ...
0
votes
1answer
34 views

apt-cache show bash script

I'm trying to write a bash script that will ask echo "What programme do you want to see?" and then give the answer as 'foo', so that 'foo' can be read by the line which says apt-cache show foo|grep -i ...
0
votes
1answer
361 views

Start script on network connect

I am trying to get a GNU/Linux Bash script to run as soon as a network connection is established on my Raspberry Pi. I tried following the instructions on several pages: I have tried adding my script ...
0
votes
2answers
374 views

How can I add some websites link to browser's favorite(bookmark) for users in domain using batch script?

I wanna add some website's link into all users bookmark(favorite in IE) automatically when user log in to windows using batch script or something like that? Is there any policy in windows server 2003 ...
1
vote
3answers
116 views

Two simultaneous commands, then sequential commands?

So in Linux, I want to run a script 4 times, then do stuff to the output. I can do: script 1 > output1.txt script 2 > output2.txt script 3 > output3.txt script 4 > output4.txt cat ...
0
votes
1answer
174 views

How can a bash script run several others scripts?

I try to make a bash script to run multiple scripts located in different directories. I tried to do something like #!/bin/bash path1="/path/to/folder1" path2="/path/to/folder2" ...
0
votes
0answers
61 views

Geany IDE save files with bash command?

Is there any way to save open files in Geany IDE with a bash command? I have a bash script to compile source files for me, but I want it to save the file before compiling. "What I would like to use ...
0
votes
1answer
97 views

New process being created while checking with 'if' in bash

ps -ef | while read line; do for i in $line; do if [ $i = 'bash' ]; then echo $line; fi; done; done; unset i; The command runs properly displaying the Bash ...
2
votes
1answer
238 views

linux find: searching for files smaller than 2Kb misses the ones between 1 and 2Kb

I just stumbled in an oddity with the find command on Linux, in a nutshell I had the need to find all files smaller than 2Kb in a certain folder, so I issued the command: find /folder_to_search_into/ ...
1
vote
1answer
187 views

How to start a watch process for a bash script that sends notifications? (ubuntu 13.04)

I have written a bash script that monitors the output of sensors and uses notify-send to alert me when my notebook is overheating. I start the script with watch -n 15 fullscriptname and also added ...
0
votes
1answer
102 views

Bash conditional redirection when testing/debugging

What is the best way to conditionally do a redirection in Bash for testing and debugging purposes? In my scripts I add a debug option to show what would have happened effectively doing a test run ...
2
votes
1answer
70 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 ...
1
vote
0answers
168 views

Automatic generation of flowchart for in- and output files from BASH script? [closed]

Often I write bash scripts that can get quite complicated, even when they do not consist of a great many lines. I comment extensively, still it is sometimes difficult to understand what output files ...
1
vote
2answers
700 views

couldn't execute “mysql”: no such file or directory, using autoexpect

I have the following file: exp.exp #!/usr/bin/expect db_host='localhost' db_name='webui_dev' db_user='root' db_pass='rootpass' new_db_name='db_2011' expect <<EOF log_user 0 spawn mysql -h ...
1
vote
2answers
88 views

Bash Script Error

I'm trying to write a bash script to manage setting up a user profile. I can't seem to figure out why this if statement won't work. I have the code: #!/bin/bash #check if programs are installed ( ...
1
vote
1answer
138 views

Stuck in a while-loop in GNU/SU (seismic unix)

I'm new to programming. I have this loop (it's part of a data processing script) and I have it all good until this section cause I can't figure out why it stay looping in the second 'while' Take a ...
2
votes
1answer
499 views

A bash script to start applications in certain workspaces [duplicate]

I'm dreaming of a Bash script that opens applications and places them in certain workspaces. For example, I'd like to run a script that: In Workspace 1 opens firefox WS2 - opens term and maximizes ...
3
votes
1answer
583 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
votes
2answers
72 views

Bash: Escaping list of files

Can this be done more nicely (echo a placeholder for another command) echo $(for x in *;do echo $x|sed 's/\([ \t\n\r\v\f\;#]\)/\^\1/g'|sed 's/$/\;/g';done) Also, there should be no ; after the last ...
0
votes
2answers
478 views

Getting error no such file or directory when running a script

Need a bit help. I just wrote my first script to change the network configuration. the code is echo "changing IP to 172.17.51.71" echo "changing Mask to 255.255.255.0" echo "changing Gateway to ...
1
vote
0answers
5k views

how to get flash video stream URL from website without browser (telediario, rtve)

I want to access the video stream URL of telediario from spanish television (RTVE) which you can find here in a flash player: http://www.rtve.es/alacarta/videos/telediario/ I want to do this with ...
2
votes
1answer
87 views

Invoke a script for every command typed at shell prompt?

On bash, is there any simple way to run a command every time another command is entered in your shell? I know about 'trap ... DEBUG', but unfortunately it does not run the specified code for every ...
0
votes
1answer
706 views

set global variable AND use stdout from bash function

Here's the code: #! /bin/bash function foo() { G1=123 echo "ReturnVal" } RV="$(foo)" echo "RV=$RV, G1=$G1" # RV=ReturnVal, G1= foo >/dev/null echo "G1=$G1" # G1=123 I want to execute ...
0
votes
1answer
1k views

Save result of a grep -c into a shell variable

How can I store the result of grep -c as an integer in a shell variable? This: check=sudo virsh list |egrep -c '\b[0-9]{2}\b' only gives me the number of matches and prints it on screen whereas ...
3
votes
2answers
116 views

Append dir to PATH

I'm trying to localy add a dir to the global $PATH variable. I added the following to my .bashrc. export PATH=$PATH:$VRS/bin But PATH seems to get concatenated to itself over & over every time ...
2
votes
2answers
450 views

Prefix to each output of a command on runtime

I am trying to make a modular script. I have several scripts/commands which are called from a single script. I want to prefix the output of each separate command. Examle: My files are allcommands.sh ...
0
votes
1answer
246 views

Getting error while executing shell script in Cygwin?

I have done a script (bash) and kept the same in E:\Ping folder of my local Windows 7 m/c, and I am trying to run the same through Cygwin. I'm getting a bash: sh : command not found error. What is ...