shell-scripting

How can I control inputs on Shell Script?

Hi I am getting parameters from user ./inputControl.sh param1 param2 ... I want users can only enter numbers. can not enter any words, etc. if they enter word i will show them error. thanks for answers ...

applescript + shell script problem

I'm writing a script to keep track of missing frames in a render (thousands of image files). to find the numbered frames in the sequence I do this: set thecontents to every paragraph of (do shell script "while IFS= read -r -d '' file; do echo \"$file\"|sed -E \"s|.*[^[:digit:]]0*([[:digit:]]+)\\..*|\\1|\" ; done< <(find \"" & thefolderP...

In UNIX shell scripting: What is $! ?

What is the meaning for $! in shell or shell scripting? I am trying to understand a script which has the something like the following. local@usr> a=1 local@usr> echo $a 1 local@usr> echo $!a a It is printing the variable back. Is it all for that? What are the other $x options we have? Few I know are $$, $*, $?. If anyone can point me ...

Shell script to grab selected text and alter it?

How can I make a shell script that will know where the caret is and grab selected text, so I can wrap the text in something? For example, this is a script from a Textmate bundle: <${1:p}>$TM_SELECTED_TEXT</${1/\s.*//}> It grabs the text and wraps it in open/close HTML tags. And it is variable so the second tag is mirrored as you type...

How to format the date in korn shell script to DD-MON-YYYY?

How do I format a date in a korn shell script to DD-MON-YYYY? I have tried the following: date '+%d-%h-%Y' It returns 04-Nov-2009 I need for the Nov to be NOV (all caps). Can this be done with the date utility? ...

calling shell script from java application

I have a java application from which i am calling a shell script. Can any one tell where to keep the script file in my application and what is the path to access the file in whole application. i m keeping my script in the java package but when i m trying to access using path like com.abc.script.sh by running my java application through ...

How do I launch an editor from a shell script?

I would like my tcsh script to launch an editor (e.g., vi, emacs): #!/bin/tcsh vi my_file This starts up vi with my_file but first displays a warning "Vim: Warning: Output is not to a terminal" and my keystrokes don't appear on the screen. After I kill vi, my terminal window is messed up (no newlines), requiring a "reset". I tried "...

Bash: what expands to all files in current directory recursively

I know **/*.ext expands to all files in all subdirectories matching *.ext, but what is a similar expansion that includes all such files in the current directory as well? ...

AWK: field separator contains a '+'

echo -n 'a001~!+rr001~!+1~!+TEST DATA 1' | awk 'BEGIN {FS="~!+"} {print $2}' I have the field separator set to "~!+" and want to print the second field. AWK prints an extraneous + with rr001 as +rr001 . What am I doing wrong? ...

How to determine the "tipping point" especially when programming regex's?

G'day, Edit: While this question covers a situation that can arise in programming a lot, i have always noticed that there is a point when working with regex's, esp. in Perl and with shell-programming, where trying to capture those last few edge cases: requires much, much more time to expand your regex, which can mean excessive complex...

validation tool for shell scripting

Is there any validation tool for shell scripting on unix platform. like after the completion of the script the tool validates it and warns us of eroors? ...

second previous command execution

hello in unix command line !! will execute th eprevious command on the command line like below indibm202 21: date Tue Nov 10 17:38:13 IST 2009 indibm202 22: !! date Tue Nov 10 17:38:16 IST 2009 indibm202 23: what is the command to execute the second previous command? ...

Eval to variable failing (w/Crontab)

Here's a snippet of a bash script I'm writing to log CPU loads: #!/bin/bash # ... irrelevant nonsense ... cmd1="/usr/bin/mpstat -P ALL | egrep '(AM|PM)([[:space:]]+)(0)' | tr -s ' ' | cut -d' ' -f4" ldsys="$(echo $cmd1 | /bin/sh)" # ... irrelevant nonsense ... $ldsys is set properly when the script is executed conventionally from the ...

How can my shell script control the placement of a zenity window?

I'm using zenity to post a simple notification when my spam-filter daemon filters a group of messages. Currently this message is posted to the middle of the screen, which is obtrusive. I want to post it to the upper left corner. However, zenity does not honor the -geometry option which is supposed to be standard for all X applications...

Setting Enviroment Variables Dynamically on Linux

I am currently looking for a way to set enviroment variables in Linux via a simple shell script. Within the script I am currently using the 'export' command, however this only has scope within the script where system-wide scope is needed. Is there anyway I can do this via a shell script, or will another method need to be used? ...

Shell variable with spaces , quoting for single command line option

Autoconf scripts have trouble with a filename or pathname with spaces. For example, ./configure CPPFLAGS="-I\"/path with space\"" results in (config.log): configure:3012: gcc -I"/path with space" conftest.c >&5 gcc: with: No such file or directory gcc: space": No such file or directory The compile command from ./configure is ac...

Case Insensitive comparision of strings in Shell script

The == is used to compare two string in shell script, however I want to compare two strings by ignoring case, how it can be done.Do we any standard command for this. ...

Bash - Recursively Create Nonexistant Subdirectories

Hello all, I am creating a quick backup script that will dump some databases into a nice/neat directory structure and I realized that I need to test to make sure that the directories exist before I create them. The code I have works, but it seems that there is a better way to do it. Any suggestions? [ -d "$BACKUP_DIR" ] || mkdir "$BACK...

Which (scripting) programming language to use for this simple web service?

I want to start a rather time consuming process using a web interface, so I obviously want it to run in a background (daemon) process and I'd also like to have a progress bar using AJAX or sth like that. My idea was to have a daemon listening for requests on a given port. The browser would then send a request with the task parameters an...

How to build one file contains other files, selected by mask?

I need to put the contents of all *.as files in some specified folder into one big file. How can I do it in Linux shell? ...