Grep on a list


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Grep on a list
# 8  
Old 01-19-2015
Quote:
Originally Posted by MadeInGermany
There are many old sed out there...
An escaped * is good style. And safe.
I have to agree with Scrutinizer here; there is no need to escape an asterisk when it is the 1st character in a BRE (as used in ed, ex, grep (without the -Eoption), sed, vi, etc.).

However, when an asterisk is used in an ERE (as used in awk (as in RavinderSingh13's suggested script), grep -E (AKA egrep on many systems), etc.), the asterisk does need to be escaped.

Some versions of sed also have an option to use EREs instead of BREs. In those versions of sed when that option is specified, the asterisk does need to be escaped.
These 2 Users Gave Thanks to Don Cragun For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep to fetch exact list

Hi I have below lists of files filename-1.0.0.tar.gz filename-1.0.1.345657676.snapshots.tar.gz so when I do grep -o 'filename-*.tar.gz' | sort | tail -1 then it consider snapshots as a part of it's result. How can I make sure, that it should only display the results from... (3 Replies)
Discussion started by: manas_ranjan
3 Replies

2. Shell Programming and Scripting

Grep and ignore list from file

cat /tmp/i.txt '(ORA-28001|ORA-00100|ORA-28001|ORA-20026|ORA-20025|ORA-02291|ORA-01458|ORA-01017|ORA-1017|ORA-28000|ORA-06512|ORA-06512|Domestic Phone|ENCRYPTION)' grep -ia 'ORA-\{5\}:' Rep* |grep -iavE `cat /tmp/i.txt` grep: Unmatched ( or \( Please tell me why am i getting that (6 Replies)
Discussion started by: jhonnyrip
6 Replies

3. Shell Programming and Scripting

grep a variable from list

I have a script to create a variable from a list, B.txt and then search it in another file, file.txt and then print the pattern line and next line. #!/bin/bash while read a do echo "$a" | grep -A 1 $a file.txt > $a\.txt done < B.txt I always get that no such file or directory exists... (6 Replies)
Discussion started by: godzilla07
6 Replies

4. UNIX for Dummies Questions & Answers

grep list of directories

Hi all, it possible creating a file with list of directories, and using grep to find pattern on only directories and subdirectories contained in that file? And it is done? regards (4 Replies)
Discussion started by: bspirit
4 Replies

5. UNIX for Dummies Questions & Answers

List and grep

Hi, My requirement is to copy all yesterdays files which have "access" keyword in their filenames to a separate folder say "/tmp/moht". Can you please let me know how? (8 Replies)
Discussion started by: shifahim
8 Replies

6. Shell Programming and Scripting

Grep a files list

Hi, I want to grep a string from the list of files present in a text file. I want the output to be printed only when the string is present in a file along with the file name.. I tried some thing like cat files_list | grep "search_string" $_ I know $_ is wrong but i want something... (7 Replies)
Discussion started by: nigas
7 Replies

7. UNIX for Dummies Questions & Answers

How to Grep list of directories

I have multiple systems with each having its own log directory containing log file pertinent to that system. I have constructed a find/grep statement to get the list of directories ending in log, but I can't seem to pipe that to grep (via xargs) to have grep search each file in the log directories... (8 Replies)
Discussion started by: jmgibby
8 Replies

8. Shell Programming and Scripting

how to grep a file in list

hi all, for an example: In a file out.txt contains: /export/home/raghu/bin/debug_serverLog_apache_20090626_0625.txt How to grep or cut the value as "debug_serverLog_apache_20090626_0625.txt" or i want only the output as "debug_serverLog_apache_20090626_0625.txt" pls advice me (3 Replies)
Discussion started by: raghur77
3 Replies

9. Shell Programming and Scripting

grep a list of values

Hi everybody! :) :D :D :) it's great to be here since this is my first post. touch /base/oracle/FRA/XMUT00/RMAN_FLAG touch /base/oracle/FRA/XRLL00/RMAN_FLAG find directory name containing RMAN_FLAG : $ find /base/oracle/FRA -name RMAN_FLAG -print|xargs -n1 dirname |sort -u... (3 Replies)
Discussion started by: jolan_louve
3 Replies

10. UNIX for Dummies Questions & Answers

List grep results

Hi I need to search for matching strings in a database and I want to print out all files that matches in "detail", which means that I want the output to contain datum of last saving. I only get the grep function tp print the actual file names which is not enough since the database is to large... (14 Replies)
Discussion started by: slire
14 Replies
Login or Register to Ask a Question