Sponsored Content
Top Forums Shell Programming and Scripting How ro handle backslash character in grep? Post 302121889 by rajbal on Monday 18th of June 2007 06:42:41 PM
Old 06-18-2007
How ro handle backslash character in grep?

Hi ,
I am doing invert grep using -v but the string contain "/" which break the grep command and it do not skip the lines with "/" on it.
Diffu.txt
========
1159c1159
< <td align="right" valign="middle" class="paddingRight2px" id="featureListItemChannelButton7466">
---
> <td align="right" valign="middle" class="paddingRight2px" id="featureListItemChannelButton2505">
1168,1169c1168,1169
< document.getElementById( 'featureListItemChannelButton7466').innerHTML = '<img src="/images/buttons/playsm_disabled.gif" alt="Subscriber Only Channel" title="Subscriber Only Channel" class="playSm" border="0" height="20" width="20" \/><br \/><br class="v5" \/>';
< Element.addClassName( 'featureListItemChannelButton7466', 'contentUnAvail' );


DiffSkiplines.txt
===========
<td align="right" valign="middle" class="paddingRight2px" id="featureListItemChannelButton7466">
document.getElementById( 'featureListItemChannelButton7466').innerHTML = '<img src="/images/buttons/playsm_disabled.gif" alt="Subscriber Only Channel" title="Subscriber Only Channel" class="playSm" border="0" height="20" width="20" \/><br \/><br class="v5" \/>';
Element.addClassName( 'featureListItemChannelButton7466', 'contentUnAvail' );


cat /home/zabbix/public_html/diffu.txt| grep -v -f /home/zabbix/public_html/DiffSkipLines.txt returns

1159c1159
---
> <td align="right" valign="middle" class="paddingRight2px" id="featureListItemChannelButton2505">
1168,1169c1168,1169
< document.getElementById( 'featureListItemChannelButton7466').innerHTML = '<img src="/images/buttons/playsm_disabled.gif" alt="Subscriber Only Channel" title="Subscriber Only Channel" class="playSm" border="0" height="20" width="20" \/><br \/><br class="v5" \/>';

but it do not removes the line with document.getElement string as it has a backslash character before "/>".
Please let me know how to get rid of lines with backslash in it??


Regards,
Raj
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep to handle a 0 result

Hi guys, I have the following grep command in a script to search through a file for a string and return its count, and it works fine for when the string exists: grep "string" file.txt | wc However, sometimes the result will be 0 and I want the script to take this as the result. Right now... (6 Replies)
Discussion started by: ocelot
6 Replies

2. UNIX for Advanced & Expert Users

How to handle backslash in grep string

Hi , I am doing invert grep using -v but the string contain "/" which break the grep command and it do not skip the lines with "/" on it. Diffu.txt ======== 1159c1159 < <td align="right" valign="middle" class="paddingRight2px" id="featureListItemChannelButton7466"> --- > <td... (6 Replies)
Discussion started by: rajbal
6 Replies

3. UNIX for Dummies Questions & Answers

Grep alternative to handle large numbers of files

I am looking for a file with 'MCR0000000716214' in it. I tried the following command: grep MCR0000000716214 * The problem is that the folder I am searching in has over 87000 files and I am getting the following: bash: /bin/grep: Arg list too long Is there any command I can use that can... (6 Replies)
Discussion started by: runnerpaul
6 Replies

4. Shell Programming and Scripting

remove backslash character from file

How do I remove a backslash character \ from a file? I have used sed -e "s|\||g" filename > newfile I have done several permutations on this to no avail such as: sed -e "s|`\`||g" filename > newfile sed -e "s|""\""||g" filename > newfile What am I doing wrong?:confused: ... (2 Replies)
Discussion started by: MissI
2 Replies

5. UNIX for Dummies Questions & Answers

grep for a backslash as for loop parameter

Hello everyone, My main objective is to search for text within a file, namely a block of text where each line ends with a backslash "\". However, the block must begin with a keyword, like "loginstring". Here is an example of a file that contains a block: ############### loginstring \... (2 Replies)
Discussion started by: idlechatter
2 Replies

6. UNIX for Advanced & Expert Users

grep for a backslash question

Why does this work when grepping for a backslash? grep '\\' .bash_history grep "" .bash_historyWhy does this not work when grepping for a backslash? grep "\\" .bash_historyI know this works works but just don't understand why I need 4 backslashes when using double quotes. grep "\\\\"... (7 Replies)
Discussion started by: cokedude
7 Replies

7. UNIX for Dummies Questions & Answers

Difference between handle to the thread HANDLE and thread identifier pthread_t

This question might be silly but its confusing me a bit: What is the difference between handle to the thread HANDLE and thread identifier pthread_t? ---------- Post updated at 01:52 PM ---------- Previous update was at 01:48 PM ---------- Sorry I saw details and HANDLE is in windows and... (0 Replies)
Discussion started by: rupeshkp728
0 Replies

8. Shell Programming and Scripting

Passing backslash character to awk variable

Hi All. I have a file that contains some special characters and I'm trying to use AWK to search for lines between <pattern1> and <pattern2>. As an example: I need the lines between the line containing ' select_id="x_0 ' and the line containing the next instance of ' from '. This is a file... (5 Replies)
Discussion started by: Mudshark
5 Replies

9. Shell Programming and Scripting

Replace special characters with backslash and character

Hi, I have a string wherein i need to replace special characters with backslash and that character. Ex: If my string is a=qwerty123@!, then the new string should be a_new=qwerty123\@\!\, Thanks (3 Replies)
Discussion started by: temp_user
3 Replies

10. Shell Programming and Scripting

How to handle variable with special character?

Hi Gurus, I have a requirement which needs to pass a parameter when calling the script, using this parameter to find a file name stored in master file. then read the file content. the issue is in the file name has a special character "$". don't know how to handle this. below is example: the... (10 Replies)
Discussion started by: green_k
10 Replies
ZGREP(1)                                                      General Commands Manual                                                     ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 02:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy