bash

Installing Ruby 1.9.2 through RVM fails.

Hi everyone, I've installed rvm following the official guide on rvm. I installed Ruby 1.8.7 with rvm install 1.8.7 and then set it as default with rvm 1.8.7 --default. Now I tried to install 1.9.2 with rvm install 1.9.2(also tried rvm install 1.9.2-head). Everything goes fine until I get to the "ruby-1.9.2-head - #installing-part. The...

How to sort find result such that paths beginning with one of a set of patterns are sorted last.

I have a find command that I would like to sort such that entries for certain directories are sorted last. The reason is that this list is to be passed to etags to create a tags table and I would like certain third-party tool directories to be after all the code I actively edit. Can someone suggest a good easy way in to sort the list a...

rsync option in a variable

Hi, I want to put command option of rsync into a variable so I can reuse it for other rsync commands. Here is what I tried but it didn't work. roption="-a --recursive --progress --exclude='class' --delete --exclude='exclude' --exclude='.svn' --exclude='.metadata' --exclude='*.class'" rsync "$roption" /media/CORSAIR/workspace ~/ Can a...

bash completion prevents backspace

I am trying to set up bash completion for a utility script I wrote, so I added the following script to /etc/bash_completion.d: _mcd() { local cur words COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" words=`mcd-completion-words` COMPREPLY=( $(compgen -W "${words}" -- "$cur") ) return 0 } complete -F _mcd mcd The ...

Serial port loopback/duplex test, in Bash or C? (process substitution)

Hi all, I have a serial device set up as loopback (meaning it will simply echo back any character it receives), and I'd like to measure effective throughput speed. For this, I hoped I could use time, as in time bash -c '...' where '...' would be some command I could run. Now, the first problem is that I want to use the device at 2...

How do I preserve whitespace and use a ceiling function with a One-Liner Awk inline edit?

Hi everyone, I have a configuration file that has variables and value separate by spaces. I want to take the value (in the second column) of certain matches and inline edit the file, dividing this match by 2. I also would like to preserve spacing and use a ceiling function on the value. For example, the file: To recap, using an actu...

git: stage only new files

Hello, When I have: dirty working directory, dirty staging area, and I copied some new files to the project, how do I stage only the new ones? git alias adduntracked=… ...

How to write find-all function (with regex) in awk or sed

I have bash function which run python (which return all finded regex from stdin) function find-all() { python -c "import re import sys print '\n'.join(re.findall('$1', sys.stdin.read()))" } When I use this regex find-all 'href="([^"]*)"' < index.html it should return first group from the regex (value of href attribute from file in...

How can I use Perl regexp characters when inside a bash script?

I would like a command line function that I can run on any file to change the include("myinc.inc"); PHP statement to include 'myfile.inc'; I have made a start by adding the following to my ~/.bashrc file: function makestandard() { perl -p -i -e 's/include\("([\w\.]+)"\)/include '$1'/g' $* } I source ~/.bashrc; and run the command ...

How to split a variable in two args with exec in TCL ?

Hello, I want to create a simple Console in Tcl/Tk I have two problems. First changing every * with a [glob *] but also, when my entry contains "ls -a" it doesn't understand that ls is the command and -a the first arg. How can I manage to do that ? Thanks proc execute {} { # ajoute le contenu de .add_frame.add_entry set valu...

how do I kill this bash script?

I have written a bash script, A, that is calling another script, B, over 1000 times in a loop. Ctrl+C kills only script B, only one iteration. Script A keeps running and calling script B again. Can I rewrite something in these scripts so that Ctrl+C will kill script A? ...

Simulating sendmail with dummy script

Hey all, I created a small shell script which logs all of it's input to a log file, with which I had thought I could replace the sendmail binary and thus achieve a simple way to simulate e-mail delivery without actually setting up a working sendmail. This failed, however. For reasons I cannot understand. I've looked at the PHP mail.c ...

Get hex time stamp from bash script

Hi, I would like to convert the current date and time into a hex time stamp, something like: Tue Feb 2 10:27:46 GMT 2010 converted into 0x6d054a874449e I would like to do this from a bash script, any idea how I might do that? Thanks J ...

Terminal on the web browser?

Is there a way to put the terminal on the web browser instead, so I just fire up localhost:80 and then I'll have a terminal on it that I can use and whatever I execute it will execute on my local web server? And the outputs I want to be displayed on the web browser too, just like a normal Terminal. I'm using Ruby on Mac OS X/Ubuntu. ...

Create an app from a bash script that accepts arguments?

Hi As it says ... in OSX can i create an application based off a bash script - that accepts arguments ? So for example i can run in terminal : open /path/to/MyBashScriptApp.app myArgument1 This app will run with the argument passed to it? I know i can rename to .command - but i need it to be an app . ...

simple use of function in shell script

Hi! I am trying to use the simple fuinction below. But i get error sayin unary oprator expected and the output is always one. Can any1 help me correct it. #!/bin/bash checkit () { if [ $1 = "none" ] then  echo "none" else  echo "one" fi } checkit ...

Display terminal output on web browser?

Here is my case: I want to use a web browser to connect to a Rails application that runs this example code on the server side: Dir.chdir path_typed_in_by_user system "ls -la" I want the output of "ls -la" to be displayed on the web browser. Is this possible somehow? ...

how to display all lines from one that match regex in linux.

I want to display all lines from one which match regular expression if I have a file foo bar123 baz12435 lorem ipsum dolor sit amet this display-from baz[0-9]* < file sould return (It doesn't matter if it display matched line or not) lorem ipsum dolor sit amet How can I do this in Linux (with sed, awk or grep) ...

Problem with using open4 in Ruby.

I have a script I want to execute with open4. Here is the file: script #!/usr/bin/env ruby print "Enter your username: " username = gets puts "Here is your username: #{username}" print "Enter your password: " password = gets puts "Here is your password: #{password}" Then I fire up IRB and type: ruby-1.9.2-p0 > pid, stdin, stdout, s...

How to check for path expansion for executables

Like most makefiles, I have some bash scripts that use variables for executables. For example, $mysql_exec for /usr/bin/mysql. I would like to be able to say something like: mysql_exec=mysql to use $PATH or mysql_exec=/usr/bin/mysql to get an absolute location without $PATH. I also want to check to see if the executable is valid u...