Script mit find und xargs. Zwei fragen

tuxlover

tuxlover

Der den Tux knuddelt
Hallo leute

ich bin mal wieder dabei ein wenig mit der bash herumzuspielen.
Wenn ich folgendes eingebe

Code:
find /usr/ -type f -name README |xargs grep grep

sucht mir find alle READMES heraus, die das Wort grep enthalten. Genau das was ich will.

Allerdings passiert bei dem folgenden Script überhaupt nichts:
Code:
#!/bin/bash

DOCUMENTS=(readme REAMDE install howto authors news todo config sample samples example examples ref guide manual quickstart thanks notes features faq acknowledgement bugs problems )
FIND=$2
SEARCH_PATH=$1

for i in ${DOCUMENTS[*]}

    do
       find "$SEARCH_PATH" -type f -name "$i" | xargs grep "$FIND"
    done

exit 0
das heißt auf der konsole wird nichts ausgegeben, warum?

Zweite Frage ist vielleicht etwas simpler, obwohl ich dazu nirgends eine entsprechende ANtwort gefunden habe. Wie kann man mit find caseinsensetive suchen, also das groß und kleinschreibung egal sind, und readme das gleiche wie ReaDme ist?

vielen dank für eure antworten

grüße

tuxlover
 
Zuletzt bearbeitet:
Tja, das sind eben Traditionen.

Du bist schliesslich auch genau so blind (oder faul, oder beides) .. wie immer.

Code:
man find  |grep -A5 -B5 case
 
Tja, das sind eben Traditionen.

Du bist schliesslich auch genau so blind (oder faul, oder beides) .. wie immer.

Code:
man find  |grep -A5 -B5 case

ok ich bin blind hast recht. :D aber da wo ich geguckt habe, stands tatsächlich nicht.

-iname ist das was ich suche.

kannst du mir vielleicht noch etwas zu dem ersten teil und dem problem mit dem script sagen?
 
ok ich bin blind hast recht. :D aber da wo ich geguckt habe, stands tatsächlich nicht.

Bitte?

Das steht auch auf der von Dir verlinkten Seite (logisch, ist ja der selbe Inhalt), sogar in "Sichtweite" zur Dir offensichtlich bekannten "-name"-Option.

-iname pattern
Like -name, but the match is case insensitive. For example, the patterns 'fo*' and 'F??' match the file names 'Foo', 'FOO', 'foo', 'fOo', etc. In these patterns, unlike filename expansion by the shell, an initial '.' can be matched by '*'. That is, find -name *bar will match the file '.foobar'. Please note that you should quote patterns as a matter of course, otherwise the shell will expand any wildcard characters in them.

-inum n
File has inode number n. It is normally easier to use the -samefile test instead.

-ipath pattern
Behaves in the same way as -iwholename. This option is deprecated, so please do not use it.

-iregex pattern
Like -regex, but the match is case insensitive.

-iwholename pattern
Like -wholename, but the match is case insensitive.

-links n
File has n links.

-lname pattern
File is a symbolic link whose contents match shell pattern pattern. The metacharacters do not treat '/' or '.' specially. If the -L option or the -follow option is in effect, this test returns false unless the symbolic link is broken.

-mmin n
File's data was last modified n minutes ago.

-mtime n
File's data was last modified n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file modification times.

-name pattern
Base of file name (the path with the leading directories removed) matches shell pattern pattern. The metacharacters ('*', '?', and '[]') match a '.' at the start of the base name (this is a change in findutils-4.2.2; see section STANDARDS CONFORMANCE below). To ignore a directory and the files under it, use -prune; see an example in the description of -wholename. Braces are not recognised as being special, despite the fact that some shells including Bash imbue braces with a special meaning in shell patterns. The filename matching is performed with the use of the fnmatch(3) library function. Don't forget to enclose the pattern in quotes in order to protect it from expansion by the shell.
 
8)
.
.
.
EDIT (autom. Beitragszusammenführung) :
.

CLOSED hat sich erledigt
 
Zuletzt bearbeitet:

Ähnliche Themen

Wie vom Script verwendete Befehle ermitteln um sie bei Bedarf nach zu installieren?

FIND mit UND-Verknüpfung im Suchstring

OpenJDK8 unter Debian7.11/sparc64/kernel 3.16 kompilieren

Prblem mit zeilenweises auslesen von Datei und schreiben nach mysql

Queue für copy Script

Zurück
Oben