Sponsored Content
Top Forums Shell Programming and Scripting Find out if multiple files have lines ending with"r" Post 302844511 by newbie2010 on Monday 19th of August 2013 10:16:30 AM
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:

Code:
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

Code:
TEST-RECORDS
/volume/testing
/volume/programs
 
INFO-RECORDS
/volume/101r     -example of line that ends in r
/volume/listingr
 
CATALOG-RECORDS
/volume/catar
/volume/catx

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:

Code:
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?
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
VGREMOVE(8)						      System Manager's Manual						       VGREMOVE(8)

NAME
vgremove - remove a volume group SYNOPSIS
vgremove [-d|--debug] [-h|--help] [-v|--verbose] VolumeGroupName [VolumeGroupName...] DESCRIPTION
vgremove allows you to remove one or more volume groups. The volume group(s) must not have any logical volumes allocated and must also be inactive (see vgchange(8) ). OPTIONS -d, --debug Enables additional debugging output (if compiled with DEBUG). -h, --help Print a usage message on standard output and exit successfully. -v, --verbose Gives verbose runtime information about vgremove's activities. DIAGNOSTICS
vgremove returns an code code of 0 for success and > 0 for error: 1 no volume group name on command line 2 error setting up freed physical volume 3 error writing freed physical volume(s) to disk(s) 4 error removing volume group from lvmtab 5 can't remove volume group containing logical volumes 6 invalid volume group name 7 volume group is active 8 not all physical volumes are online 9 error accessing volume group 10 error reading volume group data from disk(s) 95 driver/module not in kernel 96 invalid I/O protocol version 97 error locking logical volume manager 98 invalid lvmtab (run vgscan(8)) 99 invalid command line See also lvm(8), vgcreate(8), vgreduce(8) AUTHOR
Heinz Mauelshagen <Linux-LVM@Sistina.com> Heinz Mauelshagen LVM TOOLS VGREMOVE(8)
All times are GMT -4. The time now is 01:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy