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

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find out if multiple files have lines ending with"r"
# 1  
Old 08-19-2013
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

/volume/101r     -example of line that ends in r

I was trying to use this command to find out which Records had "r" but of course it returns yes when run because if even one file has a volume ending in R it would return "yes."

If I do this:

for i in `cat /tmp/*RECORDS`; do if $i grep $r>/dev/null; then echo "yes";fi;done

Then I get a load of messages "no such file or directory" and the names of the files.

I am really just trying to find out which of these files has a line ending in r, and then print yes for just that file, but I am stuck.

Does anyone have any ideas?
# 2  
Old 08-19-2013
This User Gave Thanks to joeyg For This Post:
# 3  
Old 08-19-2013

Thanks, I completely missed these!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find files in sub dir with tag & add "." at the beginning [tag -f "Note" . | xargs -0 {} mv {} .{}]

I am trying find files in sub dir with certain tags using tag command, and add the period to the beginning. I can't use chflags hidden {} cause it doesn't add period to the beginning of the string for web purpose. So far with my knowledge, I only know mdfind or tag can be used to search files with... (6 Replies)
Discussion started by: Nexeu
6 Replies

2. Shell Programming and Scripting

find . -path "*_nobackup*" -prune -iname "*.PDF" \( ! -name "*_nobackup.*" \)

These three finds worked as expected: $ find . -iname "*.PDF" $ find . -iname "*.PDF" \( ! -name "*_nobackup.*" \) $ find . -path "*_nobackup*" -prune -iname "*.PDF" They all returned the match: ./folder/file.pdf :b: This find returned no matches: $ find . -path "*_nobackup*" -prune... (3 Replies)
Discussion started by: wolfv
3 Replies

3. Shell Programming and Scripting

Using "Find" & Storing To Multiple Variables

Hello all! I'm pretty new to bash scripting, so this should be a pretty easy question to solve. For the last few hours, I've been creating a script that will list some of the following (based on a path I specify): # of directories # of files # of executable files files older than 365... (2 Replies)
Discussion started by: alphekka
2 Replies

4. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

5. Shell Programming and Scripting

Using a single "find" cmd to search for multiple file types and output individual files

Hi All, I am new here but I have a scripting question that I can't seem to figure out with the "find" cmd. What I am trying to do is to only have to run a single find cmd parsing the directories and output the different file types to induvidual files and I have been running into problems.... (3 Replies)
Discussion started by: swaters
3 Replies

6. UNIX for Dummies Questions & Answers

Sorting files ending in numbers with "sort"

I have a group of files that I need to be sorted by number. I have tried to use the sort command without any luck. ls includes* includes1 includes10 includes11 includes12 includes2 includes3 includes4 includes5 includes6 includes7 includes8 includes9 I have tried ls includes*... (6 Replies)
Discussion started by: newbie2010
6 Replies

7. Shell Programming and Scripting

awk? extract quoted "" strings from multiple lines.

I am trying to extract multiple strings from snmp-mib files like below. ----- $ cat IF-MIB.mib <snip> linkDown NOTIFICATION-TYPE OBJECTS { ifIndex, ifAdminStatus, ifOperStatus } STATUS current DESCRIPTION "A linkDown trap signifies that the SNMP entity, acting in... (5 Replies)
Discussion started by: genzo
5 Replies

8. Shell Programming and Scripting

"find command" to find the files in the current directories but not in the "subdir"

Dear friends, please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories.. it is like this, current directory contains file1, file2, file3, dir1, dir2 and dir1 conatins file4, file5 and dir2 contains file6,... (9 Replies)
Discussion started by: swamymns
9 Replies

9. Shell Programming and Scripting

Delete lines ending in "_;" using sed

I could really use some help with this issue. I'm having a lot of trouble getting my sed command to delete only the lines from my file that end with _; I'm also supposed to carry the leading 'c' down to the next line. The commands I've tried either delete everything or nothing at all. Any help... (12 Replies)
Discussion started by: turbulence
12 Replies

10. UNIX for Dummies Questions & Answers

get two strings ending with "." and starting with "."

Hi all, In unix shell, I want to get two strings ending with "." and starting with "." from a string "chan.txt" For example, a string "chan.txt". The first string is "chan" The second string is "txt" Yours Wilson (1 Reply)
Discussion started by: wilsonchan1000
1 Replies
Login or Register to Ask a Question