The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Telnet in batch file aemunathan UNIX for Dummies Questions & Answers 1 05-09-2008 07:38 AM
rename the file in batch reldb UNIX for Advanced & Expert Users 7 01-14-2008 03:43 PM
batch file ramneek High Level Programming 3 11-09-2005 02:48 AM
batch file ramneek IP Networking 1 11-08-2005 08:09 AM
Creating a batch file. spotanddot UNIX for Dummies Questions & Answers 2 06-26-2001 01:45 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-03-2001
Registered User
 

Join Date: Mar 2001
Location: UK
Posts: 20
Question Batch file update

I have a data file with 4 columns of numbers with a space delimiters.

I have a script that I can run from the command line that will insert parameters directly on the command line. For example:

script.ksh 100 200 300 400

What I am trying to do is do a mass update using a big data file, and I don't want to type in these thousands of numbers line by line. I'm sure there is a way of doing this, but I wouldn't even know what to search on to see if it's been done before.

Can anybody help please.

Thanks
Forum Sponsor
  #2  
Old 10-03-2001
Registered User
 

Join Date: Oct 2001
Location: San Francisco
Posts: 27
Assuming that your data file is called "bigdata.dat", here's a really sloppy way to do it, but it is easy-to-follow:


cat bigdata.dat |\
while read FILE ; do
script.ksh $FILE
done
  #3  
Old 10-03-2001
Registered User
 

Join Date: Mar 2001
Location: UK
Posts: 20
Hmm might work, but I've forgot to say one thing..

The shell script that I can run from the command line, has $VAR1 $VAR2 $VAR3 $VAR4 inside the script. So when I run it from the unix prompt I can put in script.ksh 1 2 3 4 for example.

So that $VAR1=1 and so on. Will the example do the same ?
  #4  
Old 10-04-2001
Registered User
 

Join Date: Oct 2001
Location: San Francisco
Posts: 27
It should work.. But, copy all your files to a temporary location and test thoroughly...

I might point out that the reason I called it "sloppy" is because it does not sanity checking on the data.. For example, it does not make sure that everything is "numeric", nor does it verify that there are 4 fields on each line of you "big data file"....

A truly better solution would be to design your "script.ksh" to accept 2 forms on input, one from the command line and the other from STDIN... The reason for this is everytime that "script.ksh" is run it must fork off a new process, which takes time... If the number of files to be updated are extremely large (say 1000 or more?) it will be a noticable difference....

If you wish to post your script.ksh here I will be delighted to offer a more comprehensive analysis for you...

- dEvNuL
  #5  
Old 10-04-2001
Registered User
 

Join Date: Mar 2001
Location: UK
Posts: 20
Smile

Thanks,

Your solution worked a treat...

Many thanks for that.. One for my handy unix comands book I me thinks..

You have just saved me having to do 20.000 rows..

:-)
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:45 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0