Sponsored Content
Full Discussion: Test command question
Top Forums UNIX for Dummies Questions & Answers Test command question Post 302334739 by fpp666 on Thursday 16th of July 2009 10:20:09 AM
Old 07-16-2009
Test command question

Hi all!

I'm new to shell scripting, and I need to do a diff between two dirs. One of them (dir_old) contains many files, and the other (dir_new) contains just a set of 8 files, all starting with MC and extension .CP.

The problem I have is that dir_old contains about 20 files that start with MC and with no extension, so I need to check if the files in dir_new exist before using the diff.

This is what I have so far:

Code:
cd $dir_old
for name in MC*
    do
        if [test -e  $dir_new$name.CP]; then
            diff -s "$name" "$dir_new$name.CP" >> logfile
        fi
    done

Thanks in advance!
 

10 More Discussions You Might Find Interesting

1. AIX

question about a 'test' command

Hi all, I have the following script.Can somone explain what it does.Thanks in advance. if test $# -lt 1 then echo "Message" exit 1 fi (2 Replies)
Discussion started by: sam_78_nyc
2 Replies

2. Shell Programming and Scripting

Another newb question: how to use test for zero-length string ?

Assume $x equals "". If I try: if test -n $x I get the "Expression syntax" error. It works in Linux but not in unix bash. In unix bourne I get "test: argument expected" (4 Replies)
Discussion started by: lumix
4 Replies

3. Programming

Test command name

I'm very new to C and could use a little help. I'm testing to make sure the command is running as it's proper name, if not then fail. if (strcmp(argv, "xinit") != 0) { fprintf(stdout, "name = %s length = %d\n",argv,l); usage(0); } This works if the command is... (3 Replies)
Discussion started by: nck
3 Replies

4. Solaris

AIX, Solaris, Linux Test Environment Design Question

AIX, Solaris, Linux Test Environment Design Question We want to set an AIX, Solaris & Linux test environment. Here are the hardware equipments: (1) A Sunfire v100 (or v120), 1GB memory, two 36GB HDD. (2) An IBM pSeries 7026, 1 GB memory, 4 9GB HDD. (3) Five external HDD with SCSI... (4 Replies)
Discussion started by: aixlover
4 Replies

5. UNIX for Advanced & Expert Users

AIX, Solaris, Linux Test Environment Design Question

AIX, Solaris, Linux Test Environment Design Question We want to set an AIX, Solaris & Linux test environment. Here are the hardware equipments: (1) A Sunfire v100 (or v120), 1GB memory, two 36GB HDD. (2) An IBM pSeries 7026, 1 GB memory, 4 9GB HDD. (3) Five external HDD with SCSI... (1 Reply)
Discussion started by: aixlover
1 Replies

6. Shell Programming and Scripting

FNG Question: Test if remote server has booted

Hello again, I have a script on my media server that wakes up my backup server, performs an 'rsync' backup, then shuts the backup server down. Currently, I have it send the Wake on LAN packet, and sleep for 5 minutes, just to give the backup server time to boot (of course it doesn't take that long,... (11 Replies)
Discussion started by: vwgtiturbo
11 Replies

7. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

8. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

9. Shell Programming and Scripting

Test command

hello, i'v trying to use the TEST command and i have some problems with it. i am trying kill all proccess wich is greater than 25. i started with - ps -f | grep -v TTY | awk '{print $4}' but i dont know how to proceed from here.. 10x a lot, Daniel. (11 Replies)
Discussion started by: dadiT
11 Replies

10. Shell Programming and Scripting

Shell grammar question: logical OR in test

Hi, I am trying to check if two input files exist before the rest of the scripts is run. Following is the code that I have but it gives me syntax error. if then echo "File not found" else echo "File found" fi (3 Replies)
Discussion started by: nua7
3 Replies
BZDIFF(1)						      General Commands Manual							 BZDIFF(1)

NAME
bzcmp, bzdiff - compare bzip2 compressed files SYNOPSIS
bzcmp [ cmp_options ] file1 [ file2 ] bzdiff [ diff_options ] file1 [ file2 ] DESCRIPTION
Bzcmp and bzdiff are used to invoke the cmp or the diff program on bzip2 compressed files. All options specified are passed directly to cmp or diff. If only 1 file is specified, then the files compared are file1 and an uncompressed file1.bz2. If two files are specified, then they are uncompressed if necessary and fed to cmp or diff. The exit status from cmp or diff is preserved. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWbzip | +--------------------+-----------------+ |Interface Stability | Committed | +--------------------+-----------------+ SEE ALSO
cmp(1), diff(1), bzmore(1), bzless(1), bzgrep(1), bzip2(1) BUGS
Messages from the cmp or diff programs refer to temporary filenames instead of those specified. BZDIFF(1)
All times are GMT -4. The time now is 01:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy