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
Problem with shell script Muki101 Shell Programming and Scripting 2 11-04-2008 05:29 PM
Problem in shell script arnie_nits Shell Programming and Scripting 1 12-12-2007 10:13 AM
shell script problem djt0506 UNIX for Dummies Questions & Answers 2 12-07-2005 11:29 PM
Problem with shell script zylwyz Shell Programming and Scripting 2 06-29-2005 02:01 PM
shell script problem jayaram_miryabb Shell Programming and Scripting 1 03-09-2005 06:38 AM

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 11-17-2008
amitpansuria amitpansuria is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 91
shell script problem

I have one file list.fdict which contains recordname and its details.

like :

NAME1:25:C:NAME LINE1:
NAME2:25:C:NAME LINE2:
CITY:25:C:City:
STATE:2:C:State:
ZIPCODE:5:N:ZIPCODE:
PHONE1:12:C:HOME PHONE:
PHONE2:12:C:BUSINESS PHONE:
I want to append news records(22 different records line) to the above file.
for this,
I want to write shell script which first check record exists then dont append
and if not exists then append it.

How do you I write such shell script in efficient way.

Regards,
Amit
  #2 (permalink)  
Old 11-17-2008
amitpansuria amitpansuria is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 91
Quote:
Originally Posted by amitpansuria View Post


I have one file list.fdict which contains recordname and its details.

like :

NAME1:25:C:NAME LINE1:
NAME2:25:C:NAME LINE2:
CITY:25:C:City:
STATE:2:C:State:
ZIPCODE:5:N:ZIPCODE:
PHONE1:12:C:HOME PHONE:
PHONE2:12:C:BUSINESS PHONE:
I want to append news records(22 different records line) to the above file.
for this,
I want to write shell script which first check record exists then dont append
and if not exists then append it.

How do you I write such shell script in efficient way.

Regards,
Amit
I m changing my problem stateemnt little.

suppose I have two files list1.cfg and list2.cfg
both files contains differentrecords details
like
List1.cfg
NAME1:25:C:NAME LINE1:
NAME2:25:C:NAME LINE2:
CITY:25:C:City:
STATE:2:C:State:
ZIPCODE:5:N:ZIPCODE:
PHONE1:12:C:HOME PHONE:
PHONE2:12:C:BUSINESS PHONE:

list2.cfg
NAME1:25:C:NAME LINE1:
NAME2:25:C:NAME LINE2:
PHONECNTR:2:N:Number of attemmpts at calling RECALLNUMBER
PHONESTATR:1:C:PHONESTAT of the current RECALLNUMBER
ZONEPHONER:1:C:Time zone of the current RECALLNUMBER
LASTDATER:10ate of last attempt on RECALLNUMBER
LASTTIMER:8:T:Time of last attempt on RECALLNUMBER
LASTSTATR:2:C:Stat of last attempt on RECALLNUMBER
FRSTDATER:10ate of first attempt to call RECALLNUMBER
FRSTTIMER:8:T:Time of first attempt to call RECALLNUMBER
FRSTSTATR:2:C:Stat of first attempt to call RECALLNUMBER

Now I want to append contents list2.cfg to list1.cfg(It ispposible using cat list2.cfg >>list1.cfg) but I want to check if content of (record) in list2.cfg is present in list1.cfg then dont append it otherwise append it.

How do I write such shell script in efficient way
Regards,
Amit
  #3 (permalink)  
Old 11-17-2008
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,937
Please put such things in [ code ] tags. like [ code ] example [ /code ] except without the extra spaces in the tags. This should prevent from being a smiley:
Code:
:D
  #4 (permalink)  
Old 11-17-2008
Christoph Spohr Christoph Spohr is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 205
Hi,

to show you the lines in only in file2 but not in file1, try:

Code:
comm -13 file1 file2
and to append them to file1

Code:
comm -13 file1 file2 >> file1
HTH Chris
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:56 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