Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-29-2012
Registered User
 
Join Date: Jun 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Exclude new line character while searching

Hi,

I have a log file and want to search "0.48976360737438795" with excluding new line character.
Currently i am using the following command:

Code:
cat LogFile.log | tr -d '\n' | grep '0.48976360737438795'

This command giving me the response if file size is small but if i am using a big file like in GB then it is not giving any response.
I have attached the log file.

Can anyone please help me on this?

Last edited by vbe; 06-29-2012 at 09:02 AM.. Reason: code tags
Sponsored Links
    #2  
Old 06-29-2012
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Ankit,

can you show here your expected result?

Regards,
Dave Null
Sponsored Links
    #3  
Old 06-29-2012
Registered User
 
Join Date: Jun 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
It should return everything whatever in the attached log file because my search string available in the every log step.
    #4  
Old 06-29-2012
jayan_jay's Avatar
Forum Advisor
 
Join Date: Jul 2008
Posts: 831
Thanks: 9
Thanked 185 Times in 176 Posts
Attachment ?? Also provide sample expected output ..
Sponsored Links
    #5  
Old 06-29-2012
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
I'm not sure why you would want to display everything in your screen when the size of the file is in GB.

Perhaps you can add "less" in your command, as it does not read the whole file before displaying.

Code:
cat LogFile.log | tr -d '\n' | grep '0.48976360737438795' | less


Last edited by vbe; 06-29-2012 at 09:03 AM..
Sponsored Links
    #6  
Old 06-29-2012
methyl methyl is offline Forum Staff  
Moderator
 
Join Date: Mar 2008
Posts: 6,388
Thanks: 286
Thanked 668 Times in 640 Posts
Once you remove all the text file line terminators the file is no longer a standard unix text file and is unsuitable for processing in unix shell tools.

What is the record format of the input file? Is is fixed length records or variable length records?

A possible method might be to create two versions of the input file, one with every even numbered line terminator removed and one with every odd numbered line terminator removed. Then search both files to determine if the string is present.
Sponsored Links
    #7  
Old 07-02-2012
Registered User
 
Join Date: Jun 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
I have attached the Input file and expected output file.
Please help me on this.
Attached Files
File Type: txt Input.txt (7.3 KB, 13 views)
File Type: txt Expected_Output.txt (6.6 KB, 11 views)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to remove new line character and append new line character in a file? sasikari HP-UX 8 10-27-2010 06:09 PM
Searching a particular character in a file gautamshaw UNIX for Dummies Questions & Answers 4 09-24-2010 05:26 PM
exclude a line big123456 Shell Programming and Scripting 3 04-24-2008 12:31 PM
Searching a string for a character turbulence Shell Programming and Scripting 7 01-12-2006 08:56 AM
searching for $ character MizzGail UNIX for Dummies Questions & Answers 4 01-05-2006 10:21 PM



All times are GMT -4. The time now is 04:09 AM.