The UNIX and Linux Forums  
Hello and Welcome from 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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Creating a file ravisg Shell Programming and Scripting 2 05-10-2008 07:15 AM
checking out latest updated file asadlone Shell Programming and Scripting 3 05-08-2008 05:16 AM
Creating a csv file based on Existing file skywayterrace Shell Programming and Scripting 3 12-02-2007 09:19 AM
/etc/utmp file does not get updated with boot up details jyoti_mil UNIX for Advanced & Expert Users 1 06-11-2007 11:41 AM
which file is updated after modified the crontab entries. krishna176 SUN Solaris 1 03-25-2007 03:42 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #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
  #2 (permalink)  
Old 09-29-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Quote:
Originally Posted by dbfree
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
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.
  #3 (permalink)  
Old 09-29-2005
dbfree dbfree is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 5
Quote:
Originally Posted by blowtorch
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.
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 ?
  #4 (permalink)  
Old 09-29-2005
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,759
Code:
tr -d '\n' < oldfile > newfile
  #5 (permalink)  
Old 09-30-2005
dbfree dbfree is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 5
Quote:
Originally Posted by jim mcnamara
Code:
tr -d '\n' < oldfile > newfile
Thanks

It was just :
Code:
tr -d '\t' < oldfile > newfile
since I had to suppress <tab> character
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0