grep - to exclude lines beginning with pattern


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grep - to exclude lines beginning with pattern
# 1  
Old 08-29-2005
grep - to exclude lines beginning with pattern

11132
13069
11137
11142
13070

Can I use grep command to exclude all lines beginning with 13?
I dont want to use grep -v 13 as potentially there will be a number with something like 11013 that I would exclude in error..
# 2  
Old 08-29-2005
You can have a regex as a search pattern for grep.

Code:
grep -v '^13' myfile

Vino
# 3  
Old 08-29-2005
Perfect- couldnt remember the syntax..

Thanks!! Smilie Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[sed] Finding and sticking the pattern to the beginning of successive lines up to the next pattern

I have a file like below. 2018.07.01, Sunday 09:27 some text 123456789 0 21 0.06 0.07 0.00 2018.07.02, Monday 09:31 some text 123456789 1 41 0.26 0.32 0.00 09:39 some text 456789012 1 0.07 0.09 0.09 09:45 some text 932469494 1 55 0.29 0.36 0.00 16:49 some text 123456789 0 48 0.12 0.15 0.00... (9 Replies)
Discussion started by: father_7
9 Replies

2. Shell Programming and Scripting

Grep all lines with the pattern .sh

Linux version : Oracle Linux 6.5 Shell : bash In the the below text file (someString.text), I want to grep all lines with .sh in it. ie. Only the lines mysript.sh and anotherscript.sh should be returned. My below attempts failed. I gather that in regular expression world, dot (.) is the... (3 Replies)
Discussion started by: John K
3 Replies

3. Shell Programming and Scripting

Exclude multiple lines using grep

Hi, I'm working on a shell script that reports service status on a database server. There are some services that are in disabled status that the script should ignore and only check the services that are in Enabled status. I output the service configuration to a file and use that information to... (5 Replies)
Discussion started by: senthil3d
5 Replies

4. UNIX for Dummies Questions & Answers

Grep -v lines starting with pattern 1 and not matching pattern 2

Hi all! Thanks for taking the time to view this! I want to grep out all lines of a file that starts with pattern 1 but also does not match with the second pattern. Example: Drink a soda Eat a banana Eat multiple bananas Drink an apple juice Eat an apple Eat multiple apples I... (8 Replies)
Discussion started by: demmel
8 Replies

5. Shell Programming and Scripting

Grep lines before a pattern having some other pattern

Hi All, I am trying to fetch lines before a pattern, I got to know about -B flag in grep but we have to pass the number to get those lines before some pattern say (X), now what if I want to get line/s with some other pattern say (Y) before X pattern? How to get about it? please help. Input:... (5 Replies)
Discussion started by: dips_ag
5 Replies

6. Shell Programming and Scripting

Grep pattern and display all lines below

Hi I need to grep for a patter and display all lines below the pattern. For ex: say my file has the below lines file1 file2 file3 file4 file5 I NEED to grep for patter file3 and display all lines below the pattern. do we have an option to get this data. Let me know if you require... (5 Replies)
Discussion started by: venkidhadha
5 Replies

7. Shell Programming and Scripting

Grep the word from pattern line and update in subsequent lines till next pattern line reached

Hi, I have got the below requirement. please suggest. I have a file like, Processing Item is: /data/ing/cfg2/abc.txt /data/ing/cfg3/bgc.txt Processing Item is: /data/cmd/for2/ght.txt /data/kernal/config.klgt.txt I want to process the above file to get the output file like, ... (5 Replies)
Discussion started by: rbalaj16
5 Replies

8. UNIX for Dummies Questions & Answers

Grep with 8 lines before and after pattern.

OK. I have a file I'd like to be able to grep, but on top of returning the line where the pattern matches, I'd like to be able to get the previous 8 lines and the following 8 lines. Is there a way to do this? (2 Replies)
Discussion started by: mrwatkin
2 Replies

9. Solaris

How to grep (say)last-3 and next-3 lines of Desired Pattern

Hi All, OS-Type=Sun-OS 5.8 Sparc9 Processor Can I grep the previous 4 lines and next 4 lines of a matched pattern(context grep)? For example here we need to monitor logs of live traffic.The data obtained from "tail -f LiveTrafficData.log" looks something like this:-... (3 Replies)
Discussion started by: Sujan Banerjee
3 Replies

10. Shell Programming and Scripting

grep to show lines only after pattern

When i grep for a pattern the search results comes up with matching lines(some before the pattern and some after)...how can i limit the search so that it shows only the lines after the pattern specified (5 Replies)
Discussion started by: wannalearn
5 Replies
Login or Register to Ask a Question