bash

using bash to get revision number from subversion

I want to write a shell script in bash to deploy websites from an svn repository. When I deploy a website, I name the exported directory *website_name*-R*revision_number*. I'd like the bash script to automatically rename the exported directory, so it needs to learn the current revision number from the export directory. If I run $> svn ...

Sort results from find and grab subset (bash)

I have a pair of bash scripts, 1 that dumps mysql dbs, and the second to purge old backups. I have always relied on date, so any files older than 7 days are purged, and new backups created daily. The result was a set of backups 7 days back. Well now that I have 20+ dbs I have separated that daily job into a daily, and weekly job. If I...

Bash and Mac OS X, open application in Space N

Hi, I wonder if it is possible in bash for OSX to create a script for which we give as input the application name and a number N, so this app gets opened in the Space's space number N. I would like with this to create a meta-script, so when the computer boots and after login, on each space I get different apps, and important, I can cha...

Storing files inside BASH scripts

Is there a way to store binary data inside a BASH script so that it can be piped to a program later in that script? At the moment (on Mac OS) I'm doing play sound.m4a # do stuff I'd like to be able to do something like: SOUND <<< the m4a data, encoded somehow? END echo $SOUND | play #do stuff Is there a way to do this? ...

How do I escape text in autoconf/m4?

The following code from my configuration.ac file does not work (note the nested square brackets with [default=no]): AC_ARG_ENABLE(debug, [ --enable-debug build with debugging support [default=no].], [DEBUG="$enableval"], [DEBUG="no"] ) How can I escape those brackets? ...

bash : Multiple Unary operators in if statement

hello, Is it possible to have multiple unary operators in if statements.. Here is the code snippet which is giving me error. Please correct the code here. if [ -f $input_file ] -a [ -f $output_file ] -a [ -f $log_file ] ] then ### Some Code here fi Thanks Kiran ...

Checking the return value of a C program in a bash script?

I have a bash script in which i check the exit code of a last run command by using $? variable but now I am executing a C program (from that script) which returns 0 if the program gets executed successfully. Is there any way I can catch this return value of the C program from with in my bash script? I believe different commands like awk...

How to use Zenity to display a files contents with tickboxes beside each line of the file

Hi Guys Im trying to give a visual output for a file listing i have. What i want to be able to do is display a tick box beside each line from the file I have thrown together the following zenity command but my main problem is my file listings can be quite long. From the command below i define the values by TRUE "" or FALSE "" My que...

Why shouldn't I use unix commands from php?

Why would you prefer to keep from using bash commands via exec() in php? I do not consider portability issue (I definitely will not port it to run on Windows). That's just a matter of a good way of writing scripts. On the one hand: I need to write much more lines in php then in bash to accomplish the same task. For example, when I n...

Compare/Difference of two arrays in bash

Hello, Is it possible to take the difference of two arrays in bash.. Would be really great if you could suggest me the way to do it.. Code : Array1=( "key1" "key2" "key3" "key4" "key5" "key6" "key7" "key8" "key9" "key10" ) Array2=( "key1" "key2" "key3" "key4" "key5" "key6" ) Array3 =diff(Array1, Array2) Array3 ideally should be : Ar...

Adding mysql to my .bashrc PATH

Ok, maybe I'm doing something really stupid. I'm on OSX 10.6.1. I want to add mysql to my path, so I add the following to my .bashrc PATH = ${PATH}:/usr/local/mysql/bin export PATH upon running terminal, it doesn't work, which I expect, because .bash_profile is not loading .bashrc at the moment. but if I manually enter bash, i get ...

Quick Unix shell scripting variable question

Say if i wanted to do this command: (cat file | wc -l)/2 and store it in a variable such as middle, how would i do it? I know its simply not the case of $middle=$(cat file | wc -l)/2 so how would i do it? ...

Script for changing C++ class names

I have moved my classes from a global namespace into a specific namespace. I have also changed the class names. I want to convert all my source files that use these classes to the new format. I was thinking either a bash script using a sed file on Cygwin or executing a perl script. I'm having troubles with the bash script. Here's th...

Git post-receive hook not working

We're using git with a central repo (using Gitosis). I've created a post-receive hook to generate an email to the dev mailing list whenever changes are pushed to the central repo, and to generate documentation from the documentation folder in the git repo. Therefore, in ~git/ I've got a directory, we'll call it 'a' that contains a clone...

How can I get `find` to ignore .svn directories?

I often use the find command to search through source code, delete files, whatever. Annoyingly, because Subversion stores duplicates of each file in its .svn/text-base/ directories my simple searches end up getting lots of duplicate results. For example, I want to recursively search for uint in multiple messages.h and messages.cpp files:...

how to assign the output of a shell command to a variable ?

Hello, I have a problem putting the content of pwd command into a shell variable that i'll use later. Here is my shell code (the loop doesn't stop): #!/bin/bash pwd= `pwd` until [ $pwd = "/" ] do echo $pwd ls && cd .. && ls $pwd= `pwd` done Could you spot my mistake please? Thanks a lot for your help...

shell: return values of test on file/directory

I'm not able to check the return values of the function test; man test didn't help me much. #!/bin/bash test=$(test -d $1) if [ $test -eq 1 ] then echo "the file exists and is a directory" elif [ $test -eq 0 ] echo "file does not exist or is not a directory" else echo "error" fi ...

SO how to make MAC recognize linux BASH?

Script runs fine in Solaris and Linux just not on the crippled MAC -- thus no build environment #!/bin/bash var0=1 LIMIT=60 mkdir Application cd Application while [ "$var0" -lt "$LIMIT" ] do mkdir "$var0"; cd $var0; for i in $(seq 1 8192); do mkdir "${i}"; cd "$i"; dd if=/dev/urandom of=a bs=4096 count=1 > /dev/...

How do I synchronize (lock/unlock) access to a file in bash from multiple scripts?

I'm writing scripts that will run in parallel and will get their input data from the same file. These scripts will open the input file, read the first line, store it for further treatment and finally erase this read line from the input file. Now the problem is that multiple scripts accessing the file can lead to the situation where two...

Help with Bash script

I'm trying to get this script to basically read input from a file on a command line, match the user id in the file using grep and output these lines with line numbers starting from 1)...n in a new file. so far my script looks like this #!/bin/bash linenum=1 grep $USER $1 | while [ read LINE ] do echo $linenum ")" $LINE >> usrout $linen...