![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep help | flood | Shell Programming and Scripting | 3 | 06-05-2008 10:14 PM |
| Grep | Aejaz | UNIX for Advanced & Expert Users | 3 | 04-30-2008 04:10 AM |
| grep | dineshr85 | Shell Programming and Scripting | 1 | 10-10-2007 01:52 AM |
| how to exclude the GREP command from GREP | yamsin789 | UNIX for Advanced & Expert Users | 2 | 10-04-2007 11:59 PM |
| Make grep -c display like grep -n? | Jerrad | Shell Programming and Scripting | 2 | 08-24-2006 09:20 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
help on grep
Hi ALL,
I have a text file with many lines containing ------- (1 or more hyphens) and i need to remove them. i used grep -v "-----" <file1> > <file2> BUT it does not work as hyphen exists. i tried \ (backslash) for escape sequence and double quotes etc. to get no improvement. Pl help me how can i remove the lines containing >=5 hyphens (e.g., ----- ) Thanks Prvn |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Guess THis should work
sed -e 's/\-//g' filename Regards, Anand |
|
#3
|
|||
|
|||
|
Your solution replaces all HYPHENs with NULL
My requirement is to remove the lines containing the string of 5 (or more) consecutive hyphens (e.g., ----- ) Thanks Prvn |
|
#4
|
|||
|
|||
|
Hope this should work
grep -v "\-" filename |
|
#5
|
|||
|
|||
|
Thanks Aajan,
grep -v "\-----" filename WORKED |
|
#6
|
||||
|
||||
|
grep -v -- - <filename> will also work; the double hypen prevents the next - from being interpreted as an option, but uses it as an arg
|
||||
| Google The UNIX and Linux Forums |