Visit Our UNIX and Linux User Community


Batch file update


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Batch file update
# 1  
Old 10-03-2001
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
# 2  
Old 10-04-2001
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-04-2001
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
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
Bug

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..

:-)
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #180
Difficulty: Medium
The Apple II was invented by Steve Jobs.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Renaming file in batch

Hi guys, I need a script to change the file names e.g.:- below are the mentioned files, i want t0 change the last character of the name 00000.cdr with e.g bep01.smsc.191214210500-00000.cdr to bep01.smsc.191214210500-92311.cdr next file be like bep01.smsc.191214210500-92312.cdr # ls -ltr... (9 Replies)
Discussion started by: mfaizan40
9 Replies

2. Shell Programming and Scripting

Executing a batch of files within a shell script with option to refire the individual files in batch

Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below. I am on a solaris server btw. Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose. ... (2 Replies)
Discussion started by: goddevil
2 Replies

3. UNIX for Advanced & Expert Users

batch file

Hi all I am using tru64 Unix and I want a ready batch file which makes me to change all user passwords at the same time ,instead of changing everyone separately. Please could anyone help me to do that. bye. (1 Reply)
Discussion started by: ahmedbashir
1 Replies

4. Shell Programming and Scripting

Batch file to remove double quotes from a file

Hi I have to create a windows batch file which will read an input file and remove "double quotes" from each line of the file. For eg.If input file name is abcd.csv and contents is : "asasd,123123,213213,asd" "esfrf,dsfsdf,234324,sdfsdf" Then the batch file should remove "" from the... (11 Replies)
Discussion started by: akashtcs
11 Replies

5. Windows & DOS: Issues & Discussions

Creating a batch file..

Hello, this is my first post and i hope you can solve my problem. I need to create a batch file that will copy folder from hard drive on to usb stick on daily basis. Can you help me and write that file and explaine me what to do next. Folder's location is: c\windows\desktop\2009 Thank... (5 Replies)
Discussion started by: hule
5 Replies

6. UNIX for Advanced & Expert Users

Batch file question

EDIT: Is this wrong thread? Hi I am on an Apple Mac and I am trying to run this batch file on my Mac and was wondering if anyone could tell me what a script that will make this run and work on my Mac. I was hoping that you could tell me the script in the shell format? So here's the batch... (4 Replies)
Discussion started by: Billy5555100
4 Replies

7. UNIX for Dummies Questions & Answers

Telnet in batch file

hi how can i connect to a telnet session using the unix script... need to create a batch file which has to run daily. first it has to telnet to a IP then execute certain commands and log the session. thanks Aemu (1 Reply)
Discussion started by: aemunathan
1 Replies

8. Programming

batch file

what is a command to call a batch file from a c++ program when called with the argument which is a text file, then how to print that text file on a printer. please help me with code if possible (3 Replies)
Discussion started by: ramneek
3 Replies

9. IP Networking

batch file

my requirment is i have to call a batch file from a c++ program that batch file is called with the argument as print.txt print.txt is a text file which should get printed on printer (any printer) when a batch file call is made 1) how to call a batch file in c++ 2) how to print the text... (1 Reply)
Discussion started by: ramneek
1 Replies

Featured Tech Videos