Exclude new line character while searching


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Exclude new line character while searching
# 1  
Old 06-29-2012
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 10:02 AM.. Reason: code tags
# 2  
Old 06-29-2012
Hi Ankit,

can you show here your expected result?

Regards,
Dave Null
# 3  
Old 06-29-2012
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
Attachment ?? Also provide sample expected output ..
# 5  
Old 06-29-2012
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 10:03 AM..
# 6  
Old 06-29-2012
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.
# 7  
Old 07-02-2012
I have attached the Input file and expected output file.
Please help me on this.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Searching invalid character in list of client name

Hi Friend, I have a client name list and client name has some invalid character due to which some issue raised and list of client are15k. I want to make script who find invalid character name. can you please help me how i can make script, i means i need logic. Valid character are :- ... (5 Replies)
Discussion started by: pallvi_mahajan
5 Replies

2. Shell Programming and Scripting

Searching Alphanumeric Character From a File

Hi, In a error log file, the error code of a particular error contains both Alphabet and Numbers. My problem statement is to find the error codes from a particular log. That means, I need to search a word, which contains both alphabet and number. Please help me. Below is two examples of error... (1 Reply)
Discussion started by: snehasish_jana
1 Replies

3. Shell Programming and Scripting

exclude blank line

hi, how can i exclude blank line along with #, in the below command. crontab -l|grep -v "^#" |wc -l thx (3 Replies)
Discussion started by: bang_dba
3 Replies

4. Shell Programming and Scripting

Awk: Searching for length of words between slash character

Dear UNIX Community, I have a set of file paths like the one below: \\folder name \ folder1 \ folder2 \ folder3 \ folder4 \\folder name \ very long folder name \ even longer name I would like to find the length of the characters (including space) between the \'s. However, I want... (6 Replies)
Discussion started by: vnayak
6 Replies

5. Shell Programming and Scripting

Have to exclude the first and last line of the file : help me

hi , i am very new to perl . scriptting.. pllease can any one help me ...pleaseeeeeee i ll have a file which look likes 123 |something |567 456 |welcome |789 457 |inboxpost |790 . . 123 |something |567 i have to execute all the lines in the file except the first and the... (14 Replies)
Discussion started by: vishwakar
14 Replies

6. HP-UX

How to remove new line character and append new line character in a file?

Hi Experts, I have data coming in 4 columns and there are new line characters \n in between the data. I need to remove the new line characters in the middle of the row and keep the \n character at the end of the line. File is comma (,) seperated. Eg: ID,Client ,SNo,Rank 37,Airtel \n... (8 Replies)
Discussion started by: sasikari
8 Replies

7. UNIX for Dummies Questions & Answers

Searching a particular character in a file

Hi, I want to search how many times is "a" present in a file named "data". How to do this? Please help (4 Replies)
Discussion started by: gautamshaw
4 Replies

8. Shell Programming and Scripting

exclude a line

Hi, thanks for your help. I wrote this script : # ! /bin/sh file=snapshot.txt cat $file | while read line ; do { myvariable=`grep "Nombre de ROLLBACK internes" |sed 's/.*.=//'` echo $myvariable } done It looks in a file "snapshot.txt" for the lines containing "Nombre de ROLLBACK... (3 Replies)
Discussion started by: big123456
3 Replies

9. Shell Programming and Scripting

Searching a string for a character

I have a co-worker that is trying to make a Wheel of Fortune game and he wants to know if there is a way to search a string for the letter given by the user. (7 Replies)
Discussion started by: turbulence
7 Replies

10. UNIX for Dummies Questions & Answers

searching for $ character

I need to search in text files for the $ character. I tried putting it in double quotes and single quotes . ie grep "$" filename but unix finds everything in the file. Whats the best way to do this? thanks (4 Replies)
Discussion started by: MizzGail
4 Replies
Login or Register to Ask a Question