Exclude new line character while searching


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Exclude new line character while searching
# 8  
Old 07-02-2012
In order to help you, please answer to Methyl's last post (#6). (REcord format etc...)
Why are you removing the newline char?
# 9  
Old 07-03-2012
Hi,

I don't want to terminate the new line character but want to ignore it while searching.
And record format is:
Record will be always start with "~~" and end with "~~" but some time the record having new line character because of it the complete record not coming if i am using the simple "grep" like:
grep "b22fdf7e-6271-4832-a014-fb1ee047c814" input.txt

In this case from the attached input file two records should return both starting with "~~" and end with "~~" but after executing above command, from the second record only the content before new line character is being returned.
# 10  
Old 07-03-2012
It's definitely not a simple text file.

I don't know about anyone else, but I can't read the sample file in Shell tools because there are one or more long records. It looks like a complex XML file and may best be read in a Java program or something more suitable for processing data files like this.
# 11  
Old 07-03-2012
I would look at these 2 products to start with:
The Expat XML Parser
XML::Parser - search.cpan.org

I Know I could do it using SAS but SAS costs $$...
# 12  
Old 07-04-2012
This is basically the log file and sometime the xml is also logged with log step.
It is working fine if i am trying on "http://regexpal.com/" with the command "^~~.*b22fdf7e-6271-4832-a014-fb1ee047c814.*~~$" with selecting
match at line breaks,
Dot matches all

But don't know how can i add the modifiers "match at line breaks" and "Dot matches all" in the grep command.
 
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