dbfree
September 29, 2005, 10:42am
1
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
Does the variable DPSTY have any value? Unless the $DPSTY has a value, the variable FILE wont either.. The 'comm' command wont work unless two filenames are supplied as arguments. And since your other arguments seem to be ok (-3) and (-12).. the problem is with the filenames supplied.
dbfree
September 29, 2005, 11:26am
3
Indeed, $DPSTY had no value, I just remplaced with FILE="DPSTY" and that runs.
Thank you.
I just have another question :
how to easily remove the <tab> character from the result records ?
tr -d '\n' < oldfile > newfile
dbfree
September 30, 2005, 3:23am
5
Thanks
It was just :
tr -d '\t' < oldfile > newfile
since I had to suppress <tab> character