Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Comparing a batch of files to a test file Post 302453208 by ladyAnne on Tuesday 14th of September 2010 11:11:20 AM
Old 09-14-2010
Comparing a batch of files to a test file

Hi

I am writing a script to run a loop through a directory and run a diff on each file against my test file.

I then want to time how long each file to process (not sure how time works), as well as how long all the files took as a whole to process.

Here is my code

Code:
#!/bin/bash
#Old file is empty. New file is full. 
#This script adds the cells to the database.
module=`basename $0`
newfile="$newfile"
dsxfile=""
DSXLOG_MODULE=$module; export DSXLOG_MODULE
dsxpids="/var/run/"
diffdir="var/local/dsx/diff"
compfile="$newfile.final"
 dsxlog $reverb --info --module="$module" "started pid = $$" 
 touch ${dsxpids}$module.pid
 printf "%i\n" $$ > ${dsxpids}$module.pid
 dsxlog $reverb --info --module="$module" "processing batch files"
 for newfile in $diffdir/*.dsx;
 do
  dsxlog $reverb --info --module="$module" "now processing ${newfile##*/}"
 /usr/local/bin/dsxdiff \
 --compatibility \
 -otestEmpty.dsx  \
 --newfile=$newfile  \
 
 
diff testEmptyFull.dsx $newfile.final > /var/local/dsx/diff/temp.dsx
if [ $? -eq 0 ]
then
 echo $testname passed
else
 echo $testname FAILED
fi
 
 done
 rm -f ${dsxpids}$module.pid
    dsxlog $reverb --warning --module="$module" "pid = $$ : Removing pid file"
 dsxlog $reverb --info --module="$module" "ended, pid = $$"


When I run it, I get the following error:

Code:
$ ./plannedFiles
diff: var/local/dsx/diff/*.dsx: No such file or directory
failed to compare files
diff: var/local/dsx/diff/*.dsx.final: No such file or directory
FAILED
 
 
I appreciate some help.
 
Thaks guys

 

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Schedule a Batch file to delete files at particular intervals

Hi, I need to write a batch file/shell script that runs at specified intervals daily and deletes specified set of files. Can anyone pls help me with the code. Thanks, Indom. (6 Replies)
Discussion started by: Indom
6 Replies

2. Shell Programming and Scripting

comparing files to contents of a file

Hi I have a problem trying to run a while statement. I have files under one directory that i need to compare to a value in filex and update that file with the result files in the directory are DFC1. DFC5. DFC345. DFC344. DFC9. The program i am trying to run will take the number... (3 Replies)
Discussion started by: SummitElse
3 Replies

3. Shell Programming and Scripting

bash - batch script for extracting one file from multiple tar files

so i have hundreds of files named history.20071112.tar (history.YYYYMMDD.tar) and im looking to extract one file out of each archive called status_YYYYMMDDHH:MM.lis here is what i have so far: for FILE in `cat dirlist` do tar xvf $FILE ./status_* done dirlist is a text... (4 Replies)
Discussion started by: kuliksco
4 Replies

4. Windows & DOS: Issues & Discussions

Batch file to Get New Files Only through FTP

Hi there I want to create a batch file which Get (mget) the newly added Files only, from specific directory on UNIX server to local folder on windows server through FTP, and this batch file will be scheduled to run daily to load the new files. help me plz :confused: (1 Reply)
Discussion started by: alsharq
1 Replies

5. Windows & DOS: Issues & Discussions

Batch file to Get New Files Only through FTP

Hi there I want to create a batch file which Get (mget) the newly added Files only from specific directory on UNIX server to specific folder on windows server using FTP, and this batch file will be scheduled on the windows server to run daily to load the new files (load the newly added files... (1 Reply)
Discussion started by: alsharq
1 Replies

6. OS X (Apple)

Batch file to move video files and retain sub-directories

I have just purchased my first ever Apple computer - and am therefore new to UNIX also. I would like to create a simple "batch file" (apologies if this is the wrong terminology) to do the following: When I plug my camera into the MAC it automatically downloads photos and videos into a new... (1 Reply)
Discussion started by: mm0mss
1 Replies

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

8. UNIX for Dummies Questions & Answers

Comparing two test files and printing out the values that do not match

Hi, I have two text files with matching first columns. Some of the values in the second column do not match. I want to write a script to print out the rows (only the first column) where the values in the second column do not match. Example: Input 1 A 1 B 2 C 3 D 4 Input 2 A 2 B 2... (6 Replies)
Discussion started by: evelibertine
6 Replies

9. Shell Programming and Scripting

Comparing two files and creating a new file

Hi, I want to compare two files based on the data in their first column. Both the files are not equal in their number of columns and number of entries or rows. The entries (only the first column) of the file1 should be compared with the entries (only the first column) of the file2. If the... (3 Replies)
Discussion started by: begin_shell
3 Replies

10. Shell Programming and Scripting

Test if Remote server is up and running before SFTP'ing files (in batch mode)

Hello, In our Data Warehouse environment, before our batch SFTP jobs kick off to pull the files from remote servers, I would like to setup a pre-sftp job that would test if all the remote servers from where the files are being pulled, are up and running. If any one of the remote serer is... (2 Replies)
Discussion started by: Dippu
2 Replies
while(n)						       Tcl Built-In Commands							  while(n)

__________________________________________________________________________________________________________________________________________________

NAME
while - Execute script repeatedly as long as a condition is met SYNOPSIS
while test body _________________________________________________________________ DESCRIPTION
The while command evaluates test as an expression (in the same way that expr evaluates its argument). The value of the expression must a proper boolean value; if it is a true value then body is executed by passing it to the Tcl interpreter. Once body has been executed then test is evaluated again, and the process repeats until eventually test evaluates to a false boolean value. Continue commands may be exe- cuted inside body to terminate the current iteration of the loop, and break commands may be executed inside body to cause immediate termi- nation of the while command. The while command always returns an empty string. Note: test should almost always be enclosed in braces. If not, variable substitutions will be made before the while command starts execut- ing, which means that variable changes made by the loop body will not be considered in the expression. This is likely to result in an infinite loop. If test is enclosed in braces, variable substitutions are delayed until the expression is evaluated (before each loop iter- ation), so changes in the variables will be visible. For an example, try the following script with and without the braces around $x<10: set x 0 while {$x<10} { puts "x is $x" incr x } SEE ALSO
break(n), continue(n), for(n), foreach(n) KEYWORDS
boolean value, loop, test, while Tcl while(n)
All times are GMT -4. The time now is 07:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy