The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 09-29-2005
dbfree dbfree is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 5
Creating an updated file

Hi,

I would like to define a script in order to update a file with the last updated records:

I wrote :

#!/bin/sh

YEAR=$(date +%Y)
MONTH=$(date +%m)
DAY=$(date +%d)

COMM=/usr/bin/comm

for file in * ;
do
if [[ "$file" = DPSTY*_$YEAR$MONTH$DAY* ]] ; then
FILE=${DPSTY}
UNIQUE=Unique_${FILE}
COMMON=Common_${FILE}
(${COMM} -3 $FILE $file) > $UNIQUE
(${COMM} -12 $FILE $file) > $COMMON
cat $UNIQUE $COMMON > $FILE
fi
done

Instead of updating the DPSTY file I got :

usage:comm [ -[123] ] file1 file2
usage:comm [ -[123] ] file1 file2

I don't know haw to do it.

Thanks