Linux Script, biit um Hilfe!

Begonnen von Steffen, 15 Januar 2016, 05:58:53

Vorheriges Thema - Nächstes Thema

Steffen

Zitat von: Wernieman am 15 Januar 2016, 10:40:42
m steht für "modifikation", c für "creation"

Besser als "--help" ist es, wenn Du mit "man" arbeitest, also "man xarg", sofern busybox dieses kann.

leider nein...
[~] # man xarg
-sh: man: command not found

dev0


Wernieman

Was sagt denn jetzt ein
find /share/CamVideo/ -type f -mtime +2

Wenn das nicht funzt, bitte testen:
find /share/CamVideo/ -type f -mmin +2880
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

Steffen

zum glück kann ich über optware nachinstallieren:


[~] # man xargs
XARGS(1)                                                                                                                             XARGS(1)



NAME
       xargs - build and execute command lines from standard input

SYNOPSIS
       xargs  [-0prtx]  [-E  eof-str]  [-e[eof-str]]  [--eof[=eof-str]]  [--null]  [-d  delimiter]  [--delimiter  delimiter] [-I replace-str]
       [-i[replace-str]] [--replace[=replace-str]] [-l[max-lines]] [-L max-lines] [--max-lines[=max-lines]]  [-n  max-args]  [--max-args=max-
       args]   [-s   max-chars]   [--max-chars=max-chars]   [-P   max-procs]  [--max-procs=max-procs]  [--interactive]  [--verbose]  [--exit]
       [--no-run-if-empty] [--arg-file=file] [--show-limits] [--version] [--help] [command [initial-arguments]]

DESCRIPTION
       This manual page documents the GNU version of xargs.  xargs reads items from the standard input, delimited by  blanks  (which  can  be
       protected  with double or single quotes or a backslash) or newlines, and executes the command (default is /bin/echo) one or more times
       with any initial-arguments followed by items read from standard input.  Blank lines on the standard input are ignored.

       Because Unix filenames can contain blanks and newlines, this default behaviour  is  often  problematic;  filenames  containing  blanks
       and/or  newlines  are  incorrectly  processed  by xargs.  In these situations it is better to use the `-0' option, which prevents such
       problems.   When using this option you will need to ensure that the program which produces the input for xargs also uses a null  char-
       acter as a separator.  If that program is GNU find for example, the `-print0' option does this for you.

       If  any invocation of the command exits with a status of 255, xargs will stop immediately without reading any further input.  An error
       message is issued on stderr when this happens.

   OPTIONS
       --arg-file=file, -a file
              Read items from file instead of standard input.  If you use this option, stdin remains unchanged when commands are run.  Other-
              wise, stdin is redirected from /dev/null.


       --null, -0
              Input  items  are  terminated by a null character instead of by whitespace, and the quotes and backslash are not special (every
              character is taken literally).  Disables the end of file string, which is treated like any other argument.  Useful  when  input
              items  might  contain  white  space, quote marks, or backslashes.  The GNU find -print0 option produces input suitable for this
              mode.

       --delimiter=delim, -d delim
              Input items are terminated by the specified character.  Quotes and backslash are not special; every character in the  input  is
              taken  literally.   Disables the end-of-file string, which is treated like any other argument.  This can be used when the input
              consists of simply newline-separated items, although it is almost always better to design your program to  use  `--null'  where
              this  is  possible.   The  specified delimiter may be a single character, a C-style character escape such as \n, or an octal or
               hexadecimal escape code.  Octal and hexadecimal escape codes are understood as for the printf command.    Multibyte  characters
              are not supported.


       -Eeof-str
              Set  the end of file string to eof-str.  If the end of file string occurs as a line of input, the rest of the input is ignored.
              If neither -E nor -e is used, no end of file string is used.

       --eof[=eof-str], -e[eof-str]
              This option is a synonym for the `-E' option.  Use `-E' instead, because it is POSIX compliant while this option  is  not.   If
              eof-str is omitted, there is no end of file string.  If neither -E nor -e is used, no end of file string is used.

       --help Print a summary of the options to xargs and exit.

       -I replace-str
              Replace  occurrences of replace-str in the initial-arguments with names read from standard input.  Also, unquoted blanks do not
              terminate input items; instead the separator is the newline character.  Implies -x and -L 1.

       --replace[=replace-str], -i[replace-str]
              This option is a synonym for -Ireplace-str if replace-str is specified, and for -I{} otherwise.  This option is deprecated; use
              -I instead.

       -L max-lines
              Use  at most max-lines nonblank input lines per command line.  Trailing blanks cause an input line to be logically continued on
              the next input line.  Implies -x.

       --max-lines[=max-lines], -l[max-lines]
              Synonym for the -L option.  Unlike -L, the max-lines argument is optional.  If max-args is not specified, it defaults  to  one.
              The -l option is deprecated since the POSIX standard specifies -L instead.

       --max-args=max-args, -n max-args
              Use at most max-args arguments per command line.  Fewer than max-args arguments will be used if the size (see the -s option) is
              exceeded, unless the -x option is given, in which case xargs will exit.

       --interactive, -p
              Prompt the user about whether to run each command line and read a line from the terminal.  Only run the  command  line  if  the
              response starts with `y' or `Y'.  Implies -t.

       --no-run-if-empty, -r
              If  the standard input does not contain any nonblanks, do not run the command.  Normally, the command is run once even if there
              is no input.  This option is a GNU extension.

       --max-chars=max-chars, -s max-chars
              Use at most max-chars characters per command line, including the command and initial-arguments and the terminating nulls at the


reicht das erstmal weil da kommt noch sehr viel oder was bestimmtes???

Mfg

Steffen

Zitat von: Wernieman am 15 Januar 2016, 11:10:45
Was sagt denn jetzt ein
find /share/CamVideo/ -type f -mtime +2


[~] # find /share/CamVideo/ -type f -mtime +2
/share/CamVideo/motion.conf

die Datei "motion.conf" ist die Älteste im Verzeichnis vom 12Jan die anderen .avi sind vom 14-15Jan werden aber bei diesem befehl nicht aufgelistet!

Mfg Steffen

Wernieman

Das ist doch richtig! Du wolltest alle Dateien, die Älter als 2 Tage sind, oder??
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

Steffen

Zitat von: Wernieman am 15 Januar 2016, 12:19:50
Das ist doch richtig! Du wolltest alle Dateien, die Älter als 2 Tage sind, oder??

Ja das stimmt, es soll später so sein alles löschen was älter als 7 tage ist, aber was danach kommt(-exec oder xargs) funktioniert ja nicht beim mir auf einem Qnap und da kommen wir gerade nicht weiter?!?

Mfg

dev0

Zitat von: Steffen am 15 Januar 2016, 10:33:04
find /share/CamVideo/ -type f | sed 's/.*/"&"/' | xargs ls -l

gibt mir das Komplette und richtige Verzeichnis wieder...
jetzt müsste mann noch -mtime einfügen oder?
[/code]
Etwas eigentständig darfst Du ruhig sein ;) Ich (wir?) habe(n) kein Busybox zum Testen.
Was ist denn das Ergebnis, wenn du -mtime einfügst?

Steffen

Zitat von: dev0 am 15 Januar 2016, 14:40:54
Etwas eigentständig darfst Du ruhig sein ;) Ich (wir?) habe(n) kein Busybox zum Testen.
Was ist denn das Ergebnis, wenn du -mtime einfügst?

eigentlich ganz gut bis -mtime +2, zeigt er richtig an aber wenn ich über 2 komme dann zeigt er das verzeichnis an wo ich mich derzeit befinde, aber müssten dann doch keine Ausgabe haben oder sehe ich das Falsch???


[~] # find /share/CamVideo/ -type f -mtime +2 | sed 's/.*/"&"/' | xargs ls -l
-rw-rw-rw-    1 admin    administ     24043 Jan 12 05:31 /share/CamVideo/motion.conf
[~] # find /share/CamVideo/ -type f -mtime +1 | sed 's/.*/"&"/' | xargs ls -l
-rw-rw-rw-    1 admin    administ     24043 Jan 12 05:31 /share/CamVideo/motion.conf
[~] # find /share/CamVideo/ -type f -mtime +3 | sed 's/.*/"&"/' | xargs ls -l
lrwxrwxrwx    1 admin    administ        45 Jan 11 07:09 Library -> /share/HDA_DATA/.qpkg/PlexMediaServer/Library
-rw-r--r--    1 admin    administ      6526 Jul 11  2007 index_default.html
[~] #

Wernieman

Irgendwie reagiert er komisch ... kannst Du bitte mal OHNE xargs es uns zeigen?
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

Steffen

Ich glaube ich habe es jetzt...


[~] # /opt/bin/find /share/CamVideo/ -type f  -mtime +1 -exec ls -l {} \;
-rw-rw-rw-    1 admin    administ     24043 Jan 12 05:31 /share/CamVideo/motion.conf
[~] # /opt/bin/find /share/CamVideo/ -type f  -mtime +2 -exec ls -l {} \;
-rw-rw-rw-    1 admin    administ     24043 Jan 12 05:31 /share/CamVideo/motion.conf
[~] # /opt/bin/find /share/CamVideo/ -type f  -mtime +3 -exec ls -l {} \;
[~] #


jetzt habe ich nochmal eine Frage zu dem + oder - bei dem -mtime warum zeigt er mir nicht bei +1 nicht die avi datein im Verzeichnis an, wo dann die jüngste 14jan und älteste 15jan ist? Wird das -mtime im gesamten zu allen Datein gemessen? Bei -mtime -1 zeigt er mir die avi alle an?!?

Aber ich denke der Code ist der Richtige....

Trotzdem nochmal riesen dank, für eure Geduld und Hilfe!!!!!

Mfg Steffen

Wernieman

-mtime bedeutet "Modifikation Zeit"
1 Bedeutet 1 Tag
-1 Einen Tag oder Jünger
+1 Einen Tag oder älter

- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

Steffen

Zitat von: Wernieman am 15 Januar 2016, 18:47:08
-mtime bedeutet "Modifikation Zeit"
1 Bedeutet 1 Tag
-1 Einen Tag oder Jünger
+1 Einen Tag oder älter

aber müsste er mir dann nicht bei +1 auch die avi vom 14.Jan anzeigen oder habe ich heute schon zu lange an diesem Problem gesessen und sehe,
den Wald vor lauter Bäumen nicht?!?

Mfg Steffen

Steffen

Guten Morgen...

so langsam verstehe ich einfach nicht warum mir das System heute nicht bei "-mtime +1" nicht eine Datei vom 14Jan(.avi) anzeigt müsste sie doch oder???

Vielleicht hat jemand doch mal bitte ein wenig Geduld für mich darüber zu schauen...

Im Ordner /share/CamVideo/ ist die älteste vom 12.Jan das ist unten angezeigte "motion.conf" die nächste wäre vom 14.Jan und die jüngste ist vom 16.Jan!

von heute:

[~] # /opt/bin/find /share/CamVideo/ -type f -mtime +1 -exec ls -l {} \;
-rw-rw-rw-    1 admin    administ     24043 Jan 12 05:31 /share/CamVideo/motion.conf
[~] #


Mfg Steffen

Wernieman

Kannst Du uns mal folgendes geben?
ls -lha /share/CamVideo/

Sorry, aber meine "Kristallkugel" ist defekt ;o)
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html