Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

0
votes
1answer
16 views

grep and search and replace in linux accepting parameters with /

I'm trying to find and replace the contents of a file using grep and sed. ```grep "#!/bin/bash" ./ | sed xargs -i 's/#!/bin/bash/#!/usr/env bash' How do I make sure that the string #!/bin/bash will ...
0
votes
1answer
33 views

Bind bash script to keypress

How do I map a keypress on a keyboard to a bash script? For example, when I press the "Esc" key, the script is run. OS: XFCE Spin Fedora 19 ---- EDIT ---- I need to set this via the console. This ...
1
vote
0answers
31 views

IDE for Bash shell scripting on Ubuntu?

I'm probably looking for the Holy Grail here, but I figured I'd ask. Is there an IDE for Bash shell scripting on Ubuntu (Ubuntu 12.04 in my case)? Something with a code editor that lets you set ...
0
votes
1answer
22 views

How to run a bash script in a daily basis on my remote server?

I have code need to be run in daily basis at my ubuntu remote server. How can I set it to go as described? Is there any console too to help me ? And this code should be activated itself as the machine ...
1
vote
1answer
29 views

Trim File Names of Tarballs Using Bash

I need to grade some source code from various students. The submission process is through Blackboard which appends to the file name a bunch of unnecessary stuff. Here is an example: Test ...
1
vote
1answer
64 views

Linux Bash “|” operator doesn't work - what am I doing wrong?

I am trying to check user password via login command like this: #echo "name\npassword" | login but the command ends without writing anything. Echo ends because of SIGPIPE. Why did login stop ...
0
votes
1answer
20 views

find files older than create its parent folder in a directory and move them there

I've been trying to create a bash script that does the following. Use the find command to search for files older than 7 days (find . -type f -mtime +7 ! -iname '.*', take the parent directory(of the ...
0
votes
1answer
17 views

How do I extract multiple files at once?

I have a number of rar files stored like so: /torrents/televisionshowS01E0$X/nameoftelevisionshow.rar where $X is a variable ={0,1,2,...,12} I would like to extract them using a single command to ...
0
votes
0answers
17 views

Vagrantfile - is rvm in ~/.rvm/scripts/rvm or ~/.rvm/bin/rvm?

I'm still learning my way around some of the more hidden files in terminal and I was trying to setup a Vagrant box with rails via shell script provisioning, with some help from these links: ...
1
vote
0answers
40 views

Postgresql query within a bash script

We are having an issue with a postgresql bash query. The output of the query from the bash script add's additional quotes around the date. Please can you help me fix it?! Script: #!/bin/sh ...
1
vote
0answers
8 views

How do I suppress the terminal window when I launch a bash script from Spotlight?

When I run a bash script from Spotlight, a terminal window launches to execute it. The window closes when the script finishes but I'd like to prevent that window from appearing on my desktop at all. ...
0
votes
1answer
29 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
24 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
157 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
0answers
29 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
62 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
26 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
1answer
33 views

nested for loops on a file to generate table size report

I have a file X with the db name & tbl name. DBNME|TBLNAME CATS|party CATS|name_addr CATS|account ACAT|transaction ACAT|position Using the file, I am capturing spaceused output from db and ...
0
votes
0answers
63 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
57 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
67 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
337 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
41 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
157 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
72 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
115 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
64 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
79 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
74 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
45 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
18 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
153 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
459 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
74 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
235 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
281 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
29 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
139 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
197 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
96 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
118 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
44 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
66 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
161 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
162 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
92 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 ...
1
vote
1answer
52 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
130 views

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

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
391 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
85 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 ( ...