shell

How to create a script/macro on windows XP?

hi there*.sh im not really feeling home in the windows world but at the moment i have to use a laptop with windows xp installed on it... the point is, that i do not have administrator privileges. Im currently working on a grails application and therefore I have to set the JAVA_HOME and GRAILS_HOME eacht time, I start the machine... Could...

Shell Script that goes up N folders in the file system

Hey there, I just found this very usefull shell script here on SO but unfortunately it's not working on Mac OS X 10.5. This is the script in question(copied it for convenience): #!/bin/bash LIMIT=$1 P=$PWD for ((i=1; i <= LIMIT; i++)) do P=$P/.. done cd $P I tried to echo $P at the very end and it's returning the right path, but...

run a unix shell command if the output doesn't have a specific number of lines

I've got a unix command sequence that goes something like: command1 | command2 | command3 | wc -l Now that I have the number of lines, I'd like to do something (run a specific command with no inputs) if the number of lines isn't equal to a specific number. My shell scripting is fantastically rusty (perhaps 10 years or more since I've...

Using date to append filename to database backups made by cron

Hello, The title says it all. I want to maintain multiple dated backups via cron but I can't seem to figure out how to concatenate the file name in cron. Currently I just use the following: /bin/mv /var/www/vhosts/mysite.org/dbBackups/today.sql /var/www/vhosts/mysite.org/dbBackups/yesterday.sql /usr/bin/mysqldump --add-drop-table -...

Naming: BEGIN ~ END vs LIVE ~ EVIL block structured languages

Curly Bracket languages are well known: (wikipedia) Other programming languages can have BEGIN ~ END vs LIVE ~ EVIL block structuring. eg A) BEGIN ~ END, DO ~ END, IF ~ END IF - examples: Ada, Modula, Pascal, PL/I, Ruby etc... B) IF ~ FI, DO ~ OD, CASE ~ IN ~ OUT ~ ESAC - examples: Action!, ALGOL 68, Bourne shell, Co...

How does MacPorts install packages? How can I activate a Ruby installation done via MacPorts?

After trying to install ruby19 on my machine (PPC, Mac OSX 10.5.7) using the following commandline sudo port install ruby19 the version of ruby didn't change ruby -v => ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0] I assume that i have two versions of it installed on my mac, but how do i use the latest one now? ...

how to write a folder recursive script using bash

the problem is as the title. thx! ...

Replacing all the numbers with their currency format in given line of text

I want to write a Shell (AWK, Sed also fine) program to take as a input a SINGLE line of text. Which will have arbitrarily spread integer strings in it. e.g "12884 and 111933 are two numbers and 323232 is also a number" I want the output to be "12,884 and 1,11,933 are two numbers and 2,23,232 is also a number" If this was PHP a sim...

Entry in Shell Context Menu with Icon ?

Hi All, Seeing how Notepad++ does this, is it possible to achieve something like this: http://i28.tinypic.com/fm2gs6.png using Registry class? Pointers in the right direction would be highly appreciated. Have it working great without icon now. :) i31.tinypic.com/ekokgi.png I think registering icon is going to be harder. Thank...

Cat magic - end of input

When "cat > xx.txt << EOF" is entered on the command line, further input from cmdline goes to file xx.txt until EOF is written. EOF is not a sacred word here, if instead the command was cat > xx.txt << BBB, then cmdline input goes to xx.txt until BBB is written. I don't know whats the rationale behind ( << end_of_input_sequence)this. C...

Temporary Input Redirection in Bash

I am looking for a way to dump input into my terminal from a file, but when EOF is reached I would like input returned back to my keyboard. Is there a way to do this with Bash (or any other commonly-available *nix shell)? Details: I am debugging a server program which executes a fork to start a child process. Every time I start a debu...

Multiple grep search/ignore patterns

I usually use the following pipeline to grep for a particular search string and yet ignore certain other patterns: grep -Ri 64 src/install/ | grep -v \.svn | grep -v "file"| grep -v "2\.5" | grep -v "2\.6" Can this be achieved in a succinct manner? I am using GNU grep 2.5.3. ...

Windows 7 Libraries

Hi there I hope someone can help me with this as I'm unable to find the right method to do it. I am currently developing an application that should ,in a part of it, be able to enumerate all the Windows Libraries and display their contents as well. For now I was able to get the included folders for all the standard windows 7 libraries, ...

command substitution but without breaking output into multiple arguments

Is there a way to do command substitution in BASH shell without breaking output into multiple arguments? I copy the path of some directory (from the location bar in a GUI file browser) to clipboard and then issue the following command, where the command xsel returns the clipboard content, which is the path of the directory in this case:...

How do I get grep to keep the file/pipe open?

I am trying to debug some errors in a live Merb app. There are a lot of lined of error code running by, but I jut need to see the first one. I can use grep to select these lines and print them but it closes as soon as it reached the end of the file. What I would like to do is use grep like the shift-F mode in less where it will keep t...

SUS/POSIX shell-compliant replacement of '-nt' test

I'm working on porting bash script to SUS/POSIX-compliant shells. I was able to remove most of bashisms myself but I'm currently stuck with last one. The script is for generating crontab based on files in cron.d directory, and it uses '-nt' test to check whether any of input files has changed since last time the crontab was generated. ...

Get current working directory name in Bash Script

How would I get just the current working directory name in a bash script, or even better, just a terminal command. pwd gives the full path of the current working directory, e.g. '/opt/local/bin' but I only want 'bin' ...

display message on command "cd production"

I wish to accomplish the following: If I execute "cd production" on bash prompt, I should go into the directory and a message should be displayed "You are in production", so that the user gets warned. ...

simple shell script in cygwin

#!/bin/bash echo 'first line' >foo.xml echo 'second line' >>foo.xml I am a total newbie to shell scripting. I am trying to run the above script in cygwin. I want to be able to write one line after the other to a new file. However, when I execute the above script, I see the follwoing contents in foo.xml: second line The second time...

Piping SQL to mysql via -find -exec

I cannot for the life of me get this. Example of fails, the last line of which adds in sed, which is the ultimate goal: find -maxdepth 1 -name "*.sql" -exec "mysql -D ootp < {}" \; find -maxdepth 1 -name "*.sql" -exec "mysql -D ootp << {}" \; find . -maxdepth 1 -name \"*.sql\" -exec /usr/bin/mysql -D ootp << sed -e 's/ , );/1,1);/g' {} ...