The UNIX and Linux Forums  
Hello and Welcome from United States 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
Record count of a csv file ajaykk Shell Programming and Scripting 5 07-17-2008 05:16 PM
Record count problem using sed command ayanbiswas UNIX for Dummies Questions & Answers 2 07-02-2008 07:59 AM
record count dr46014 Shell Programming and Scripting 4 12-11-2007 04:39 PM
Need help with Isql record count johnu122 Shell Programming and Scripting 4 11-18-2006 12:31 PM
How to count the record count in an EBCDIC file. oracle8 UNIX for Dummies Questions & Answers 1 07-26-2006 07:22 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-29-2008
er_zeeshan05 er_zeeshan05 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 29
replaying a record count with another record count

i use unix command to take the record count for a file1
awk 'END{print NR}' filename

i already have a file2 which conatin the count like
...
..
rec_cnt=100
..
..
I want to replace the record in the file2 using the record i take from file1.
suggest me some simple ways of doing it
thanks

  #2 (permalink)  
Old 10-29-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
This should give you the desired output:

Code:
awk '
NR==FNR{next}
FNR==1{n=NR-1}
/rec_cnt=/{$0="rec_cnt=="n}1' file1 file2
Regards
  #3 (permalink)  
Old 10-30-2008
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,078
Code:
sed 's/rec_cnt=[0-9][0-9]*/rec_cnt='`wc -l file1`'/' file2
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 05:38 PM.


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