shell

How to check if a variable is set with bash?

How do I know if a variable is set in bash? For example, how to check if the user gave the 1st parameter to a function? function a { ?? if $1 is set } ...

run python command line arguments in shell script

I have a script which takes in few arguments ./hal --runtest=example where example = /home/user/example.py how can I pass these arguments in shell script? ...

Where can I learn about the "shell:" URI?

I just realised there is a shell: URI, but every search engine seems to think shell: and shell are the same thing. The only thing I've found out is that you can type shell:startup right in explorer (XP & 7 tested) for obvious effects. This is good already because there is no %startup%, but I want to know what else is this capable of. I...

How Can I Get My File Association to Open Multiple Files in a Single Program Instance?

I have set up a file extension in the Registry for my program as Windows requires. In the Registry, under shell/open/command, I've got: "C:\MyProgramPath\MyProgram.exe" "%1" This works fine for me. When someone clicks on one or more files associated with my application, my application correctly opens the file(s) but each one is ope...

Adding an incrementing value attribute to every tag in xml using script

I want to add an attribute to every tag in my xml, which is incrementing using either awk, sed, perl or plain shell cmd For Eg: <tag1 key="123"> <tag2 abc="xf d"/> <tag3 def="d2 32"> </tag3> </tag1> I am expecting the following output <tag1 key="123" order="1"> <tag2 abc="xf d" order="2"/> <tag3 def="d2 32" order="3"> ...

Find long filenames using GNU find -regex

Hi I'm trying to find all long filenames in a directory using: find . -regex './[^/]\{5,\}.txt' According to the GNU find documentation, -regex uses emacs regex by default. So this should give me all files longer than 5 characters (excluding extension). Unfortunately it does not work. It matches nothing. I've tried various variation...

Why is this program segfaulting?

I've written a program called Mathtext. This program gives plain text "style" by shifting certain character ranges into Unicode ranges such as 'mathematical letterlike symbols" to produce plain-text italics, bold, serif, etc. It works as a line-by-line interpreter, like a shell, outputting the translated line after a line is entered. Th...

Best(?) way to make a popup menu for semi-portable shell scripts?

Basically I would love to say: echo `grep ^foo /usr/share/dict/words | popup_menu` ...and have some type of keyboard navigable menu popup or selection tool, very similar to how vim's ":Explore" mechanism works. Extreme bonus points for "easy and works pretty much everywhere with standard tools" Also acceptable is "needs some sort ...

need to connect to two different db from sqlplus

I need to take information from two different data bases. select * from TABLE_ONDB2 where column_on_db2 in ( select column_on_db1 from TABLE_ONDB1 ); Problem is both are on different db instances so I am not able to figure out how to put table names and column names etc. I hope my question is clear. ...

Shell Script That Can Check if it Was Backgrounded at Invocation

Hi All, I have written a script that relies on other server responses (uses wget to pull data), and I want it to always be run in the background unquestionably. I know one solution is to just write a wrapper script that will call my script with an '&' appended, but I want to avoid that clutter. Is there a way for a bash (or zsh) script...

sed + without cat command

hi the following syntax target is to add "_name4" on the first string in line that match the "name1 + name2 + name3" and to replace old word with new cat file | sed '/name1 + name2 + name3/s/[^ ]*\>/&_name4/' | sed s'/old/new/g' > new_file my question : is it possible to do the same without using cat command? ...

Convert special characters in bash shell script

How do I write a bash shell script (under Mac OS X) to convert the names of various files with special characters such as ä, ö, ü? Using sed doesn't work: echo * | sed s/ü/ue/ Can I do it some other way? EDIT Here is the full script. It basically zips up iPhone app packages and then (should) convert any special characters in the zip...

Why mkdir fails to work with tilde (~)?

When I write mkdir("~/folder1" , 0777); in linux, it failed to create a directory. If I replace the ~ with the expanded home directory, it works fine. What is the problem with using ~ ? Thanks ...

modify shell script to delete folders as well as files

My shell script: #!/bin/bash if [ $# -lt 2 ] then echo "$0 : Not enough argument supplied. 2 Arguments needed." echo "Argument 1: -d for debug (lists files it will remove) or -e for execution." echo "Followed by some path to remove files from. (path of where to look) " exit 1 fi if test $1 == '-d' then find $2 -mmi...

sed + match the first word in line and the second word that begin with abc

How to match all lines that begins with word ADDRESS and the second string start with abc characters. remark - ( I need to combine the sed syntax in my shell script) for example more file ADDRESS abc1a (match) ADDRESS abc1b (match) ADDRESS acb1a (will not match) ADRESS abc (will not match) ADDRESS abc2a (will match) ADDRE...

Programatic file associations in OS X.

Is it possible to use an Apple Script or a Unix executable to associate a file type with an app? My problem is I'm using File Vault and it forgets previous associations (it's a well known bug so it seems). For instance, I like to use Flying Meat's Acorn for my graphics files rather than Preview. I can Cmd-I, change all, and while it sti...

Bash script - How to take todays date and count back monthly for a year

Hi, I've made a bash script executing a PHP file: #!/bin/bash php upgrade_attendance.php refresh_daily_attendance 2010-10-01 2010-11-01 php upgrade_attendance.php refresh_daily_attendance 2010-09-01 2010-10-01 php upgrade_attendance.php refresh_daily_attendance 2010-08-01 2010-09-01 php upgrade_attendance.php refresh_daily_attendance ...

Shell script to sort lines by version and build numbers (line_5.4.3-2)

I have a text file with entries representing build tags with version and build number in the same format as debian packages like this: nimbox-apexer_1.0.0-12 nimbox-apexer_1.1.0-2 nimbox-apexer_1.1.0-1 nimbox-apexer_1.0.0-13 Using a shell script I need to sort the above list by 'version-build' and get the last line, which in the abov...

Running an executable file on Ubuntu

I am trying to run a C/C++ program on Ubuntu. So at first g++ didn't work at all in the shell, so I installed it using the command sudo aptitude update && sudo aptitude install g++ so it installed it, and when I wrote the most simplest program it compiled g++ -Wall a.cpp -o d But when i tried to execute it just wrote "d" on the c...

comint-previous-matching-input in emacsw32 is not interactive

I have been using emacsw32 for a year or so, and I never even realized that meta+r is supposed to be interactive and show hits right away! This works in the unpatched emacsw32 client (which is also much newer, btw). Wondering if anyone knows why this is? Is it the patching breaking it or is it the older emacs? Its not very old though, s...