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 and shell scripting languages 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 07:11 AM
File operations monks UNIX for Dummies Questions & Answers 2 04-26-2006 08:26 AM
File operations chiragmistry21 Shell Programming and Scripting 2 03-27-2006 06:00 PM
where i can find list of UNIX commands for daily operations ? mgoutham UNIX Desktop for Dummies Questions & Answers 1 03-02-2006 02:35 PM
mathematics operations in unix cesar720213 UNIX for Dummies Questions & Answers 2 11-22-2001 11:24 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 02-07-2008
nivas
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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----
  #2 (permalink)  
Old 02-07-2008
alamitab alamitab is offline
Registered User
  
 

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

Join Date: Feb 2008
Posts: 33
grep -f file1 file2 > out.txt
  #4 (permalink)  
Old 02-08-2008
nivas
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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 04:32 AM.. Reason: vB Codes
  #5 (permalink)  
Old 02-08-2008
nivas
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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
  #6 (permalink)  
Old 02-08-2008
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
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.
  #7 (permalink)  
Old 02-08-2008
nivas
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Unix File operations

how to use this vb codes??
Closed Thread

Bookmarks

Tags
unix commands

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 10:18 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