The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Unix file operations(shell script) nivas Shell Programming and Scripting 6 02-07-2008 03:11 AM
File operations monks UNIX for Dummies Questions & Answers 2 04-26-2006 04:26 AM
File operations chiragmistry21 Shell Programming and Scripting 2 03-27-2006 02:00 PM
where i can find list of UNIX commands for daily operations ? mgoutham UNIX Desktop for Dummies Questions & Answers 1 03-02-2006 10:35 AM
mathematics operations in unix cesar720213 UNIX for Dummies Questions & Answers 2 11-22-2001 07:24 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-07-2008
Registered User
 

Join Date: Jan 2008
Posts: 81
Unix File operations

Hi,

Iam having the two files as follows:

file1:

ASQWEDFR09876543121234512
POIUYTREW09876512345676788
ZXCVBNMKS1209888888888888

file2:
ASQWEDFR09876543121234516 asdcvfgbtg@abc.com 0000000-90-1239--2008 8990----
CXADFGTU09876543121234789 asdcvfgbtg@abc.com 0000000-90-1239--2008 8990----
KLOPIUYRE09876541234234516 asdcvfgbtg@abc.com 0000000-90-1239--2008 8990----
ZXSDCVFG09876512345634516 asdcvfgbtg@abc.com 0000000-90-1239--2008 8990----


i WANT TO update the contents in file1 to file2 and remove the other lines.

example.:

ASQWEDFR09876543121234516 asdcvfgbtg@abc.com 0000000-90-1239--2008 8990----
POIUYTREW0987651234567678 asdcvfgbtg@abc.com 0000000-90-1239--2008 8990----
ZXCVBNMKS1209888888888888 asdcvfgbtg@abc.com 0000000-90-1239--2008 8990----
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-07-2008
Registered User
 

Join Date: Jan 2007
Posts: 24
paste file_update file_to_be_updated | awk ' { print $1" " $3" "$4}' > final
cat final > file_to_be_updated
Reply With Quote
  #3 (permalink)  
Old 02-07-2008
Registered User
 

Join Date: Feb 2008
Posts: 33
grep -f file1 file2 > out.txt
Reply With Quote
  #4 (permalink)  
Old 02-08-2008
Registered User
 

Join Date: Jan 2008
Posts: 81
Unix File operations

Hi,

Thanks for your reply. It is working fine, but iam having the file 2 as follows:

file 2
Code:
QWERTYUI098765432112345  abc@soft.com                                                                            2007-09-260012275.80 0000924 00245.00 2007-10-25ASDFRESS,POIU                                                 S                                000000000000015.52 000000000000000.00 CBB00010000000906
file 1
Code:
QWERTYUI098765432112345
QWIUYTUI098765432112345
CDXRTYUI098765432112345
While iam pasting from unix box to here, the contents are not in one single line.

The above info in file1 is all in a single line.

Now i want to take the lines one by one in file1 and find if there is matching record in file 2 and if it finds it should replace and most important is it should not disturb the other info in the particular line.( Previous paste command is working but it is disturbing the spaces and it is removing those spaces in file 2.


Please give me the solution.

Thanks in advance.

Last edited by vgersh99; 02-08-2008 at 12:32 AM. Reason: vB Codes
Reply With Quote
  #5 (permalink)  
Old 02-08-2008
Registered User
 

Join Date: Jan 2008
Posts: 81
Unix File operations

Here also in file 2 , there is 40 spaces in between the email id and the next number. while copying it is not correctly pasted.

Thanks
Reply With Quote
  #6 (permalink)  
Old 02-08-2008
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 2,994
Quote:
Originally Posted by nivas View Post
Here also in file 2 , there is 40 spaces in between the email id and the next number. while copying it is not correctly pasted.

Thanks
use vB Codes when posting code or data samples.
Reply With Quote
  #7 (permalink)  
Old 02-08-2008
Registered User
 

Join Date: Jan 2008
Posts: 81
Unix File operations

how to use this vb codes??
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0