logo
down
shadow

grep to exclude a symbol in the beginning


grep to exclude a symbol in the beginning

By : markus.f
Date : January 12 2021, 08:33 AM
This might help you Search for a < or > other than the first/last non-whitespace char which should be angle brackets.
code :
grep '^\s*<.*[<>].*>\s*' 
grep '^\s*<.*[<>].*>\s*' << EOF
>  <instrument F001="6-A-1046" INSTRUMENT_ID="<xyz>" >
>   <field fieldname="CUR007" value="<EUR>"/>
>   <field fieldname="C207" value="2023-01-11"/>
>   <field fieldname="INS160" value="0"/>
>   <field fieldname="PRD013" value="1020"/>
>   <field fieldname="PRD150" value="0"/>
>   <field fieldname="PRD205" value="0"/>
>  </instrument>
> EOF
<instrument F001="6-A-1046" INSTRUMENT_ID="<xyz>" >
 <field fieldname="CUR007" value="<EUR>"/>


Share : facebook icon twitter icon
Use grep --exclude/--include syntax to not grep through certain files

Use grep --exclude/--include syntax to not grep through certain files


By : Elena
Date : March 29 2020, 07:55 AM
wish helps you I'm looking for the string foo= in text files in a directory tree. It's on a common Linux machine, I have bash shell: , Use the shell globbing syntax:
code :
grep pattern -r --include=\*.{cpp,h} rootdir
grep: grep -v to exclude a file but doesn't work

grep: grep -v to exclude a file but doesn't work


By : Pete Milliet
Date : March 29 2020, 07:55 AM
hop of those help? Since you did not put *html in quotes, the shell expands your command to
code :
ls | grep -v a.html b.html
grep -v "a.html" b.html
ls | grep -v "html$"
# Note that html$ is the regexp equivalent to the shell pattern *html
shopt -s extglob # turn on extended globbing
ls -d !(*html)
grep from the beginning of a file (grep -f )

grep from the beginning of a file (grep -f )


By : Nikita Agarwal
Date : March 29 2020, 07:55 AM
around this issue grep -f is for file containing the patterns.
You cannot call grep -f '^-' because it will not take the '^-' as pattern, but as file name
code :
a
abc
abcd
fbdf
grep to exclude pattern and exclude 2 preceding lines

grep to exclude pattern and exclude 2 preceding lines


By : tim glen
Date : March 29 2020, 07:55 AM
it should still fix some issue Tested on GNU sed, syntax/feature might vary with other implementations
code :
sed -E 'N;N; /[acgt]{3}cc[acgt][acgt]{3}/d' ip.txt
SUBLIME & GREP: Conduct a GREP search, but exclude lines that are in all in capitals

SUBLIME & GREP: Conduct a GREP search, but exclude lines that are in all in capitals


By : WoodyGSD
Date : March 29 2020, 07:55 AM
it helps some times You could use a negative lookahead asserting what is on the right is not only uppercase chars with possible horizontal whitespace chars.
code :
^(?![A-Z\h]+$)\h*(?:\S\h*){13,}$
shadow
Privacy Policy - Terms - Contact Us © voile276.org