bash

Why does GIT not use the core.editor and commit.template configuration values when running from the bash command prompt?

When I run commit from a standard command prompt it is opening the configured editor defined by the core.editor configuration value and uses the template defined by commit.template. However when I run commit from the bash command prompt it is ignoring these settings and opening the VI editor without the template. Why is this? I am n...

Grep 'hg incoming' result for specific files and save result - if there is files im looking for

Hi! I want to create a script that will do something if hg incoming -v contains specific file. Say if hg incoming -v | grep models.py > 0 than do ./manage.py resetdb. Something like this. How can i set a flag (in bash script) based on hg incoming -v | grep manage.py result? ...

In Bash, how to add "Are you sure [Y/n]" to any command or alias?

In this particular case, I'd like to add a confirm in Bash for Are you sure? [Y/n] for Mercurial's hg push ssh://[email protected]//somepath/morepath, which is actually an alias. Is there a standard command that can be added to the alias to achieve it? The reason is that hg push and hg out can sound similar and sometimes when...

String concatenation for a bash script command

I'm trying to write an alias in my ~/.bashrc of this form: alias a="foo; osascript -e 'tell application "Terminal" to do script "bar"; baz" (where bar launches in a new Terminal window, as per this question) but this string doesn't look like it will parse. I tried string interpolation (${str}), but the problem seems to be unsolvable t...

Run multiple commands in multiple Terminal windows with a single bash line

Here's an interesting problem: Using the AppleScript method to launch a new command in a Terminal window fails if Terminal is "busy"; more precisely, it will open a new window but fail to run the command. For example, try copy+pasting this line in: osascript -e 'tell application "Terminal" to do script "foo"'; osascript -e 'tell applica...

Starting a process over ssh using bash and then killing it on sigint

I want to start a couple of jobs on different machines using ssh. If the user then interrupts the main script I want to shut down all the jobs gracefully. Here is a short example of what I'm trying to do: #!/bin/bash trap "aborted" SIGINT SIGTERM aborted() { kill -SIGTERM $bash2_pid exit } ssh -t remote_machine /foo/bar.sh & b...

How to return a string value from a bash function

I'd like to return a string from a bash function. I'll write the example in java to show what I'd like to do: public String getSomeString() { return "tadaa"; } String variable = getSomeString(); The example below works in bash, but is there a better way to do this? function getSomeString { echo "tadaa" } VARIABLE=$(getSomeS...

get week of year from day of year

Given day of year, how can I get the week of year by using Bash? ...

Writing a custom bash-completion rule.

I have directories full of files with the same prefix, which I want to be able to quickly open in vim. For example, I might have: $ ls * bar: bar_10 bar_20 bar_30 foo: foo_10 foo_20 foo_30 What I want is to be able to be in one of these directories and type: $ vim <TAB> and it autocomplete to: $ vim bar_ To achieve this I a...

cron : how to schedule to run first Sunday of every month

Hi I need to schedule a cron job to run at at 9:00 AM on first Sunday of every month. Did a little research and see that there is no short hand in cron to this. Do you know of an optimal way ? Using Bash+RHL ...

Merging Multiple KML Files

I cannot find a script to easily merge kml files; any ideas? Ideally I'd like something along the lines of kmlmerge $file $file, as I'm already working on a shell script for managing multiple kismet drone nodes. ...

Process Group Id in UNIX

Hi, I am trying to do some process control in a script (bash). For this reason I output the process group id of the current process to a file. ps ax -o '%p %r'|perl -ne 'if ($_ =~ /\s*$$\s*(\d+)/) { print "$1"; exit; }' > $pgidfile nohup $JAVA_HOME/bin/java -cp somejar.jar some.java.Program & > /dev/null 2>&1 I have also tried: ps ...

How to find the difference between 2 files in shell script

There are 100 files in dir and there are 2 pairs of file. I want to find the difference between 2 files in shell script File 1: Operating System : Windows XP Operating System : Windows NT Operating System : Windows 2008 FILE 2: Windows XP Windows NT Windows2008 ( e.g Windows 2008 ( file 1 ) and Windows2008 ( file2) ) . But fina...

Get list of USB devices connected currently and their dev file in BASH

What is the bash command for detecting all currently connected USB devices and getting the /dev/tty... file that corresponds to the USB device. ...

Redirect STDIN in bash?

For an example i would like to login to mysql with a password. i KNOW i can use -pmypass but i want to learn how do i redirect stdin in bash. So my test is mysql -u limited_user -p <text to redirect into stdin when it prompts for my pass> I seen < filename before but i dont want to store the data in a file. I tried & and &- but had no...

I have a bash-tab-completion script. Is there a simple way to use it from zsh?

I have a bash-tab-completion script for Apache's Hadoop. Normally, I use zsh as my day-to-day shell. It tends to be pretty bash-like when I need it to be, but it looks like the tab-completion systems are radically different between them. Is there a simple way to "convert" the existing bash-tab-completion definitions to work in zsh? I...

Finding a version number using grep

Basically i am creating an update checker for emesene on osx. I need to find out the version number from inside this file: http://emesene.svn.sourceforge.net/viewvc/emesene/trunk/emesene/Controller.py The version number is found at self.VERSION = 'version' in the file e.g. self.VERSION = '1.6.3' The version number then needs to be save...

How to change argv0 in bash so command shows up with different name in ps?

In a C program I can write argv[0] and the new name shows up in a ps listing. How can I do this in bash? ...

Pass Date to a C program from Shell Script

Hello, I want to pass the date entered by a user in format YYYY/MM/DD HH24:MI:SS to the C program which further makes the entry in the DB. When I am passing the entered date in the command line argument as '2010/07/15 12:13:14', the C program considers this as 2 arguments and not 1. We are using getopt function to fetch the command line ...

Get hash value using bash

Hi, I need to get the PID value out of a variable(containing hash data) using BASH. eval errors because of the array inside of it. This script is on an iPhone. eval "$(launchctl list com.3radicateRD)" eval: line 10: syntax error near unexpected token `(' eval: line 10: ` "ProgramArguments" = (' ---------------------------------------...