shell

What does "$$" means in shell script?

I came across "$$" expression in shell script, something like this TFILE=$$ Can anyone tell me its meaning? ...

find latest version of rpms from a mirror

I want to write a script to find the latest version of rpm of a given package available from a mirror for eg: http://mirror.centos.org/centos/5/updates/x86%5F64/RPMS/ The script should be able to run on majority of linux flavors (eg centos, redhat, ubuntu). So yum based solution is not an option. Is there any existing script that does t...

What's the best way to edit a text file record using shell?

I have data file that stores records like this: make=honda|model=civic|color=red make=toyota|model=corolla|color=blue What would be the best way to detect (based on the make field) whether a given make exists in the file and then replace it with a new record? (Using shell script) ...

how to Enter data from keyboard in shell programming

how to Enter data from keyboard in shell programming ? some command similar to scanf in c ...

how to create a array in unix shell programming

how to create a array in unix shell programming ? and i have to excute the program still i press a key similar to do u want to continue option ...

data validation for date data type in unix ?

for eg if i m getting various inputs from keyboard ie Book accession number, Subject code Book_id , Author , Year of Publication, Title of the book, Publisher’s name, Price, and i want do validations such that year of publication must be before 1996, Book_id must be unique, Publisher, Author and the title of the Book cannot be enter...

Why does this linux shell command halt the system?

Warning: malicious code. Do not try this. It appears here for educational purposes only. If you type this shell snippet in your shell, your system seems stopped, do you know why? :() { :|:& }; : # the only thing you can do is reboot your system.. Can you gimme some explanation ...

Parent and Child Shell Script Problem

Hi , I have two scripts parent.sh and child.sh. There is a variable in parent.sh which needs to be accessed by the child process. I have achieved this by exporting the variable in the parent script and the variable is available to the child process? Is there any way that child can modify the value of the export variable defined in par...

PHP - What's the difference between escapeshellarg and escapeshellcmd?

PHP has 2 closely related functions, escapeshellarg() and escapeshellcmd(). They both seem to do similar things, namely help make a string safer to use in system()/exec()/etc. Which one should I use? I just want to be able to take some user input and run a command on it, and not have everything blow up. If PHP had an exec-type-function ...

Unix Find Replace Special Characters in Multiple Files

I've got a set of files in a web root that all contain special characters that I'd like to remove (Â,€,â,etc). My command find . -type f -name '*.*' -exec grep -il "Â" {} \; finds & lists out the files just fine, but my command find . -type f -name '*.*' -exec tr -d 'Â' '' \; doesn't produce the results I'm looking for. Any thou...

Find symlinks to certain directory or one of its subdirs

Is there an easy way to show whether there are any symlinks in a specified path pointing to a certain directory or one of its children? ...

Creating a ShortCut IShellLink And The Preview Image In Windows 7

In Windows 7 you can create a Shortcut (on the desktop for example) of am image and the image is displayed as the Icon (with a short cut arrow overlaid). This is done by the operating system when you right click on the image and choose Send To -> Desktop (create Shortcut). I want to replicate the creation of this shortcut. Available i...

how to create a database btable from unix shell?

how to create a database btable from unix shell? and how to access the contents of the data table or to add to the table. can i create a table in ms-acces and use it throug shell? or please sugest some e-books or sites to refer ...

Exporting a function in shell

Please tell me how to export a function in parent shell (bash , sh or ksh) so that the function will be available to all the child process launced from the parent process? ...

A simple small shell script to compute averages

Can anyone tell me what I'm doing wrong here? #!/bin/sh if [ $# = 0 ] then echo "Usage: $0 <filename>" exit 1 fi sum=0 count=0 while [ $0 != 0 ] do sum="$sum"+"$2" count="$count"+ 1 done if [ "$count" != 0 ] then avg="$sum"/"$count" printf "Sum= $sum \n Count= $count \n Avg= $avg" exi...

how to redirect complete output of a script

I have a simple cronjob running every day at 18:35: 05 18 * * * ~/job.sh 2>&1 >> ~/job.log So the output of ~/job.sh should be written into ~/job.log. In job.sh, there are some echo commands and a few python scripts are executed, e.g.: echo 'doing xyz' python doXYZ.py Now, whatever output the python scripts produce, they are not wr...

Shell Script to update multiple databases

This is what I currently have: #!/bin/bash # Shell script to backup MySql database MyUSER="root" MyPASS="password123" MYSQL="$mysql" MYSQLDUMP="$mysqldump" # Store list of databases DBS="" # Get all database list first DBS="$($MYSQL -u $MyUSER -h -p$MyPASS -Bse 'show databases')" for db in $DBS do The problem i have is the 'do' b...

Korn Shell - Test with variable that may be not set

I have the following code in KornShell FAILURE=1 SUCCESS=0 isNumeric(){ if [ -n "$1" ]; then case $1 in *[!0-9]* | "") return $FAILURE; * ) return $SUCCESS; esac; else return $FAILURE; fi; } #... FILE_EXT=${FILE#*.} if [ isNumeric ${FILE_EXT} ]; then echo "...

Capturing Groups From a Grep RegEx

I've got this little script in sh (Mac OSX 10.6) to look through an array of files. Google has stopped being helpful at this point: files="*.jpg" for f in $files do echo $f | grep -oEi '[0-9]+_([a-z]+)_[0-9a-z]*' name=$? echo $name done So far (obviously, to you shell gurus) $name merely holds 0, 1 or 2...

not able to run .sh file using java

Hi All, I have a .sh file which i am trying to run using runtime api It runs perfectly if .sh file is under main project folder but I want it to be access from outside the project folder example:/home/test/test.sh when i try to run this i get /home/test/test.sh not found error Can anyone tell me how to execute .sh file using runtime a...