Visit Our UNIX and Linux User Community


General find /grep question: files with lines ending in r


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers General find /grep question: files with lines ending in r
# 8  
Old 08-19-2013
Quote:
Originally Posted by newbie2010
MadeinGermany:

I do not have the grep -q option but it looks like it is just a quiet option from online man page. The command you gave returns the file list, but again, all the files that have sentences that end in other letters as well as r are returned. I am trying to find the files that do not have ANY lines that end in r. Thanks for the help though, I will see if parts of that command are useful or if the tee command could help.
No this is not true:
if there are matching and not matching lines grep happily returns an exit status 0, this is negated, so is not printed.
Do you have Solaris? Then run /usr/xpg4/bin/grep

But -v is not working, because grep is already happy about one not matching line.
# 9  
Old 08-25-2013
Works just Great, what does it mean?

Corona:

The awk command you gave me works just fine but how to interpret it? I have searched for similar code and can't find it. Does it mean if A does not end in R then print the line? I am confused by the FILENAME syntax and the ++ at the end of FILENAME:

Code:
awk '{ A[FILENAME] } /r$/ { A[FILENAME++} END { for(X in A) if(!A[X]) print X }' *

Does it mane if A does not end in r then print it and skip ++ the Filename if it does end in r?
# 10  
Old 08-26-2013
Another way to do what I think you want is:
Code:
find . -name '*RECORDS' ! -exec grep -q 'r$' {} \; -print

which will print a list of files with names ending with "RECORDS" that do not contain a line ending with an "r".
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #334
Difficulty: Easy
For security reasons, Android versions are not named in alphabetical order.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find pattern; grep n lines before and after

Hi, I need help to grep a specific part of a log file (bold). 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: } 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: extensionContainer <Not Present> 24/2/2017-16:57:17.056... (8 Replies)
Discussion started by: vasil
8 Replies

2. Shell Programming and Scripting

How to find files containing two specific lines and delate those lines?

Hi I need to find files in a specified folder where are two specified lines of text and delate that lines. It looks like this" 35. ?>NL 36. <iframe>.......</iframe>NLThe problem is that "?>" is in the other lines and id should not be removed if the next line is not like "<iframe>....." So... (4 Replies)
Discussion started by: androwida
4 Replies

3. Shell Programming and Scripting

Find out if multiple files have lines ending with"r"

I am trying to find out which files in a group of files have lines ending in r. What I have is this: cat /tmp/*RECORDS| if grep r$>/dev/null; then echo "yes";else echo"no";fi Records is more than one file. There are the following files TEST-RECORDS /volume/testing /volume/programs ... (2 Replies)
Discussion started by: newbie2010
2 Replies

4. Shell Programming and Scripting

Perl XML, find matching condition and grep lines and put the lines somewhere else

Hi, my xml files looks something like this <Instance Name="New York"> <Description></Description> <Instance Name="A"> <Description></Description> <PropertyValue Key="false" Name="Building A" /> </Instance> <Instance Name="B"> ... (4 Replies)
Discussion started by: tententen
4 Replies

5. Shell Programming and Scripting

Regex in grep to match all lines ending with a double quote (") OR a single quote (')

Hi, I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file: Name = "abc" The regex I'm using to match the same is: egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Discussion started by: NanJ
6 Replies

6. Shell Programming and Scripting

General question about the relationship between KSH and sed/grep/awk etc

Greetings all, Unix rookie here, just diving into ksh scripting for the first time. My question may seem confusing but please bear with me: If I'm understanding everything I'm reading properly, it seems like the ksh language itself doesn't have a lot of string manipulation functions of... (2 Replies)
Discussion started by: DalTXColtsFan
2 Replies

7. Shell Programming and Scripting

Quick question on grep: grabbing lines above and below

Just a quick question on grep/egrep. I am writing a shell script that is looking for certain strings in a text file. It works well and gets exactly what I need. However, the way the program writes to the text file, it puts the timestamp in a line above the string I am looking for and the path... (3 Replies)
Discussion started by: thecoffeeguy
3 Replies

8. Shell Programming and Scripting

general question?

Perl, Python, and PHP are these languages easy to use? Are they command line or are they part of a GUI? (2 Replies)
Discussion started by: wmosley2
2 Replies

9. UNIX for Dummies Questions & Answers

grep something to find which files, lines contain something

in aix, i use grep something * to get the files, lines that contain something. but i couldnt get the same result from a sun box. what is the equivalent? thanks (4 Replies)
Discussion started by: yls177
4 Replies

10. UNIX for Dummies Questions & Answers

General Question

Hi, I've been racking my brains trying to remember, but, whats the command to change the default shell? I'm currently always in the Korn shell and I want to start out in the Bash shell. I'm running a variant of BSD I guess in Mac OS X 10.2.2 and Mandrake. Thanks. ccindyderek:confused: (4 Replies)
Discussion started by: ccindyderek
4 Replies

Featured Tech Videos