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
urgent-extracting block data from flat file using shell script shirish_cd Shell Programming and Scripting 4 02-06-2008 09:05 AM
How to Block/Ban Traffic From Specific Referrer osoamor UNIX for Dummies Questions & Answers 4 01-12-2007 03:58 PM
Is extracting specific files from a zip file possible? HLee1981 UNIX for Dummies Questions & Answers 1 10-15-2005 12:06 AM
Parsing file and extracting the useful data block arminder Shell Programming and Scripting 5 03-07-2005 09:37 AM
block telnet to specific port xiamin IP Networking 5 03-20-2002 08:51 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 02-25-2008
Dastard Dastard is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 47
Arrow Extracting specific block

Hi Everyone , have a great day

i have a file which has almost 20,000 blocks each starting with this particular line " rTCCreditControlRecord " , how can i bring out the 7172 block out of that file

Thanks in Anticipation
  #2 (permalink)  
Old 02-25-2008
bobbygsk bobbygsk is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 90
Try both the following commands.
Quote:
grep '\rTCCreditControlRecord..*$' file
or
grep '^rTCCreditControlRecord..*$' file
  #3 (permalink)  
Old 02-25-2008
Dastard Dastard is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 47
Arrow

Not working , meanwhile i have tried something like this

HTML Code:
while IFS= read -r EachLine
do
   'echo $EachLine
   if $EachLine = 'rTCCreditControlRecord'; then
   count = count + 1
   fi
   if count = 7172; then
   echo $EachLine
   fi
done < CCN02
where CCN02 is input file but its not working either
  #4 (permalink)  
Old 02-25-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink string vs. numeric comparisons

if count = 7172; then
>>>that is a string comparison

if count -eq 7172; then
>>>that is a numeric comparison

I think you would want the numeric comparison.
  #5 (permalink)  
Old 02-25-2008
Dastard Dastard is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 47
Unhappy

-r: is not an identifier

HTML Code:
#!/bin/sh
while IFS= read -r EachLine
do
   #echo $EachLine
   if $EachLine = 'rTCCreditControlRecord'; then
   count = count + 1
   fi
   if count -eq 7172; then 
   echo $EachLine
   fi
done < CCN02
Not Working
  #6 (permalink)  
Old 02-25-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Question Put in an echo to display progress

Add a display to echo to the screen what is happening. Could be count problem, $EachLine problem, file problem, etc...
By the way, wouldn't $EachLine be equal to the full line? rTCCreditControlRecord abcdefg 12345?

Code:
#!/bin/sh
while IFS= read -r EachLine
do
   #echo $EachLine
   if $EachLine = 'rTCCreditControlRecord'; then
   count = count + 1
   fi
   echo $count $EachLine   #for debug purposes
   if count -eq 7172; then 
   echo $EachLine
   fi
done < CCN02
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 06:04 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