shell

CVS branch name from tag name

I have a number of modules in CVS with different tags. How would I go about getting the name of the branch these tagged files exist on? I've tried checking out a file from the module using cvs co -r TAG and then doing cvs log but it appears to give me a list of all of the branches that the file exists on, rather than just a single branch...

uniq - skipping last N characters/fields when comparing lines

'man uniq' documents the -f=N and -s=N options which make uniq skip the first N fields/characters respectively when comparing lines, but how would you force uniq to skip the last N fields/characters? ...

extract specific folder in shell command using unzip

My backup.zip has the following structure. OverallFolder lots of files and subfolders inside i used this unzip backup.zip -d ~/public_html/demo so i end up with ~/public_html/demo/OverallFolder/my other files. How do i extract so that i end up with all my files INSIDE OverallFolder GOING DIRECTLY into ~public_html/demo? ~/publ...

converting string to lower case in bash shell scripting

Hi, Is there a way in bash shell scripting so that I can convert a string into lower case string. For example, if $a = "Hi all" I want to convert it to $a = "hi all" Thanks a lot for your help ...

In emacs, how do I customise which shell is used to start processes when using M-x comint-run

I run emacs on windows. I use cygwin and I have cygwin versions of ruby and rdebug installed as well. When I invoke M-x comint-run ENTER rdebug ENTER, I noticed that it is attempting to run rdebug.bat via the Microsoft Command prompt, instead of using bash to run rdebug (without the .bat). I'd like comint-run to use bash to invoke any pr...

Howto to receive shell events in a service

How do I get events about changed files, directories and media in a Windows service? ...

Korn Shell - Set "-x" (debug) flag globally?

Is there a way to set the debug mode(set -x) on a KornShell script globally? Currently it seems I have do something like the following: a(){ set -x #commands } b(){ set -x #more commands } set-x a #commands b I would really like to only have to call the set-x command in one place. Note: This is all in KSH88 on AIX. E...

is there a shell command to insert a string of characters in every line of a file

is there any shell command to insert a string of characters in every line of a file.. < in the beginning or the end of every line > ...

How can I grep for a value from a shell variable?

I've been trying to grep an exact shell 'variable' using word boundaries, grep "\<$variable\>" file.txt but haven't managed to; I've tried everything else but haven't succeeded. Actually I'm invoking grep from a Perl script: $attrval=`/usr/bin/grep "\<$_[0]\>" $upgradetmpdir/fullConfiguration.txt` $_[0] and $upgradetmpdir/fullConf...

How to echo directories containing matching file with Bash?

I want to write a bash script which will use a list of all the directories containing specific files. I can use find to echo the path of each and every matching file. I only want to list the path to the directory containing at least one matching file. For example, given the following directory structure: dir1/ matches1 matches...

JavaScript interpretor in Bash

Is there a JavaScript interpretor available in Bash (or for that matter any other shell) just like there is for Perl and Python. I have written some JavaScript code as part of web programming and was wondering if its used as a shell scripting language as well? Note : Please feel free to edit this question, if it feels subjective. ...

Restrict application to one instance per shell session on Windows

There are a lot of solutions for restricting an application from running twice. Searching by process name, using a named mutex etc. But I all of these methods don't work if I want to restrict my application to the shell session. A user may have more than login session and shell on windows (right?)? If this is true I want to be able to r...

How to make shell scripts robust to source being changed as they run

Hi Folks, Have people noticed that if you modify the source of a shell script, any instances that are currently running are liable to fail? This in my opinion is very bad; it means that I have to make sure all instances of a script are stopped before I make changes. My preferred behavior would be that existing scripts continue running...

The origin of using # as a comment in Python?

So I just had like this mental explosion dude! I was looking at my Python source code and was reading some comments and then I looked a the comments again. When I came across this: #!/usr/bin/env python # A regular comment Which made me wonder, was # chosen as the symbol to start a comment because it would allow the python program to ...

Custom shells started automatically from .emacs

I would like to start a few shells, and set their directories from my .emacs. Opening them is easy: ;; run a few shells. (shell "*shell5*") (shell "*shell6*") (shell "*shell7*") But I would like to specify their directory, too. ...

Create a pipe that writes to multiple files (tee).

I would like to create a pipe in a ksh script (using exec) that pipe's to a tee, and sends the output to a pipe. Current: #Redirect EVERYTHING exec 3>&1 #Save STDOUT as 3 exec 4>&2 #Save STDERR as 4 exec 1>${Log} #Redirect STDOUT to a log exec 2>&1 #Redirect STDERR to STDOUT What'd I'd like to do (but I don't have the syntax correct)...

How can I execute a shell command using VBA?

Hello, I want to execute the shell command: "C:\Temp\gc.exe 1" but I want to do it using Visual Basic for Applications. How can I do it? Thanks in advance! ...

Shell scripting noob -- how scriptable is this task?

I have a somewhat convoluted deploy procedure that I'd love to script. I'm not sure how easy or hard it will be. Here's what needs to happen: sftp myApp.war from my local machine to Server A sftp myApp.war from Server A to Server B (presumably ssh-ing in to Server A in order to run sftp on Server A) run jar xvf unab.war on Server B W...

obtain output of command to parse in in c / MacOSX

I'm working on a Command Line app to help me on launchd tasks to know if a task is running by returning a BOOL, the problem comes when i need to do a command line and obtain the output for further parsing. i'm coding it in C/C++ so i can't use NSTask for it, any ideas on how to achieve the goal? The Command sudo launchctl list -x [job...

Is it possible to do a grep with keywords stored in the array?

Hello, Is it possible to do a grep with keywords stored in the array. Here is the possible code snippet... Please correct it args=("key1" "key2" "key3") cat file_name |while read line echo $line | grep -q -w ${args[c]} done At the moment, I can search for only one keyword. I would like to search for all the keywords which is stored...