Aller au contenu


- - - - -

Commande Trouver Et Déplacer En ssh


9 réponses à ce sujet

#1 davelboss

    Qnapeur fidèle

  • Membres
  • PipPip
  • 20 messages
  • Matériel: TS-119

Posté 02 janvier 2012 - 09:54

Bonjour,

Voici le problème que je rencontre:
Je possède un QNAP119 sur lequel est connecté un disque USB externe qui stoque toute ma musique dans divers sous dossiers. Mon objectif est de supprimer cette arborescence et de mettre l'ensemble des mp3 à la racine du disque.

Plusieurs possibilités:

Depuis le webfilemanager:
problème: l'aborescence est trop importante, et la recherche n'affiche que 100 résultats par page. De plus, le soft bug lorsque j'essaie de déplacer vers la racine. Il ne se passe rien.

FTP:
Problème:Impossible de faire de recherche dans l'aborescence.

Seul moyen trouvé, une connexion en SSH.
Voici la commande tapée:
# find -iname *.mp3 -exec mv {} /mp3 \;

Problème, la commande find fonctionne mais pas le déplacement?

Quel est la commande pour trouver des fichiers dans une arborescence puis les déplacer??

Merci pour votre aide.

David

#2 cris

    Administrateur

  • Administrateurs
  • 2 567 messages
  • LocationFernelmont
  • Matériel: TS-459 Pro, TS-419P, TS-409 Pro

Posté 02 janvier 2012 - 10:17

la commande find du nas est très simpliste,



Citation


[~] # find --help
BusyBox v1.01 (2011.11.11-17:19+0000) multi-call binary

Usage: find [PATH...] [EXPRESSION]

Search for files in a directory hierarchy. The default PATH is
the current directory; default EXPRESSION is '-print'

EXPRESSION may consist of:
-follow Dereference symbolic links.
-name PATTERN File name (leading directories removed) matches PATTERN.
-print Print (default and assumed).

-type X Filetype matches X (where X is one of: f,d,l,b,c,...)
-perm PERMS Permissions match any of (+NNN); all of (-NNN);
or exactly (NNN)
-mtime TIME Modified time is greater than (+N); less than (-N);
or exactly (N) days



le seul moyen est d'utiliser un
mv *.mp3 /share/Multimedia/musique par exemple ou créer un fichier bash pour traiter en masse dans des répertoires multiples.

cris
Avant de poser votre question, pensez à vérifier si vos disques se trouvent dans la liste de compatibilité
- Besoin d'aide?
- Plugmedia [Alternative de la station multimedia]

#3 davelboss

    Qnapeur fidèle

  • Membres
  • PipPip
  • 20 messages
  • Matériel: TS-119

Posté 02 janvier 2012 - 14:46

Merci,

La commande citée fonctionne bien mais ne prend pas en charge les sous dossiers. Existe t-il une solution simple qui permettrait de combiner la commande find et la commande mv.
Je ne sais pas comment réaliser un bash. Je rappelle mon besoin:
Trouver et déplacer en masse des fichiers dans une sous arborescence telle que pourrait le faire la commande suivante qui malheureseuesment ne fonctionne pas.

find *.mp3 -exec mv {} /share/Multimedia/musique \; (pourquoi ça marche pas???

Merci de votre aide.

David

#4 cris

    Administrateur

  • Administrateurs
  • 2 567 messages
  • LocationFernelmont
  • Matériel: TS-459 Pro, TS-419P, TS-409 Pro

Posté 02 janvier 2012 - 15:24

car l'implémentation de find dans la busybox n'accepte pas le exec

sinon:

cp $(find -name *.mp3) final_temp/

cp ou mv...
Avant de poser votre question, pensez à vérifier si vos disques se trouvent dans la liste de compatibilité
- Besoin d'aide?
- Plugmedia [Alternative de la station multimedia]

#5 father_mande

    Qnapeur officiel

  • Administrateurs
  • 3 243 messages
  • Matériel: TS-459 Pro, TS-219, TS-109 II

Posté 02 janvier 2012 - 17:04

Bonjour,

Essayer avec le find complet ... (Optware ipkg)
[~] # /opt/bin/find --help
Usage: /opt/bin/find [path...] [expression]
default path is the current directory; default expression is -print
expression may consist of: operators, options, tests, and actions:
operators (decreasing precedence; -and is implicit where no others are given):
	  ( EXPR )   ! EXPR   -not EXPR   EXPR1 -a EXPR2   EXPR1 -and EXPR2
	  EXPR1 -o EXPR2   EXPR1 -or EXPR2   EXPR1 , EXPR2
positional options (always true): -daystart -follow -regextype
normal options (always true, specified before other expressions):
	  -depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf
	  --version -xdev -ignore_readdir_race -noignore_readdir_race
tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N
	  -cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME
	  -ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN
	  -links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE
	  -nouser -nogroup -path PATTERN -perm [+-]MODE -regex PATTERN
	  -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N
	  -used N -user NAME -xtype [bcdpfls]
actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print
	  -fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit
	  -exec COMMAND ; -exec COMMAND {} + -ok COMMAND ;
	  -execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ;
Report (and track progress on fixing) bugs via the findutils bug-reporting
page at http://savannah.gnu.org/ or, if you have no web access, by sending
email to <bug-findutils@gnu.org>.
[~] #


idem pour le mv
[~] # /opt/bin/mv --help
Usage: /opt/bin/mv [OPTION]... [-T] SOURCE DEST
  or:  /opt/bin/mv [OPTION]... SOURCE... DIRECTORY
  or:  /opt/bin/mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
Mandatory arguments to long options are mandatory for short options too.
	  --backup[=CONTROL]	   make a backup of each existing destination file
  -b						   like --backup but does not accept an argument
  -f, --force				  do not prompt before overwriting
  -i, --interactive		    prompt before overwrite
  -n, --no-clobber			 do not overwrite an existing file
If you specify more than one of -i, -f, -n, only the final one takes effect.
	  --strip-trailing-slashes  remove any trailing slashes from each SOURCE
								 argument
  -S, --suffix=SUFFIX		  override the usual backup suffix
  -t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY
  -T, --no-target-directory    treat DEST as a normal file
  -u, --update				 move only when the SOURCE file is newer
								 than the destination file or when the
								 destination file is missing
  -v, --verbose			    explain what is being done
	  --help	 display this help and exit
	  --version  output version information and exit
The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable.  Here are the values:
  none, off	   never make backups (even if --backup is given)
  numbered, t	 make numbered backups
  existing, nil   numbered if numbered backups exist, simple otherwise
  simple, never   always make simple backups
Report mv bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'mv invocation'

Philippe.
QNAP TS-459, 3.6.0, Virtualbox, OpenVPN
QNAP TS-109, Debian Squeeze
QNAP TS-219P II, 3.6.1
La théorie, c’est quand on sait tout et que rien ne fonctionne. La pratique, c’est quand tout fonctionne et que personne ne sait pourquoi.
Le Raid N'EST PAS un backup (proverbe Qnapien)

#6 cris

    Administrateur

  • Administrateurs
  • 2 567 messages
  • LocationFernelmont
  • Matériel: TS-459 Pro, TS-419P, TS-409 Pro

Posté 03 janvier 2012 - 21:16

Voir le messagefather_mande, le 02 janvier 2012 - 17:04 , dit :

Bonjour,

Essayer avec le find complet ... (Optware ipkg)
[~] # /opt/bin/find --help
Usage: /opt/bin/find [path...] [expression]
default path is the current directory; default expression is -print
expression may consist of: operators, options, tests, and actions:
operators (decreasing precedence; -and is implicit where no others are given):
	  ( EXPR )   ! EXPR   -not EXPR   EXPR1 -a EXPR2   EXPR1 -and EXPR2
	  EXPR1 -o EXPR2   EXPR1 -or EXPR2   EXPR1 , EXPR2
positional options (always true): -daystart -follow -regextype
normal options (always true, specified before other expressions):
	  -depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf
	  --version -xdev -ignore_readdir_race -noignore_readdir_race
tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N
	  -cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME
	  -ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN
	  -links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE
	  -nouser -nogroup -path PATTERN -perm [+-]MODE -regex PATTERN
	  -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N
	  -used N -user NAME -xtype [bcdpfls]
actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print
	  -fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit
	  -exec COMMAND ; -exec COMMAND {} + -ok COMMAND ;
	  -execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ;
Report (and track progress on fixing) bugs via the findutils bug-reporting
page at http://savannah.gnu.org/ or, if you have no web access, by sending
email to <bug-findutils@gnu.org>.
[~] #


idem pour le mv
[~] # /opt/bin/mv --help
Usage: /opt/bin/mv [OPTION]... [-T] SOURCE DEST
  or:  /opt/bin/mv [OPTION]... SOURCE... DIRECTORY
  or:  /opt/bin/mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
Mandatory arguments to long options are mandatory for short options too.
	  --backup[=CONTROL]	   make a backup of each existing destination file
  -b						   like --backup but does not accept an argument
  -f, --force				  do not prompt before overwriting
  -i, --interactive			prompt before overwrite
  -n, --no-clobber			 do not overwrite an existing file
If you specify more than one of -i, -f, -n, only the final one takes effect.
	  --strip-trailing-slashes  remove any trailing slashes from each SOURCE
								 argument
  -S, --suffix=SUFFIX		  override the usual backup suffix
  -t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY
  -T, --no-target-directory	treat DEST as a normal file
  -u, --update				 move only when the SOURCE file is newer
								 than the destination file or when the
								 destination file is missing
  -v, --verbose				explain what is being done
	  --help	 display this help and exit
	  --version  output version information and exit
The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable.  Here are the values:
  none, off	   never make backups (even if --backup is given)
  numbered, t	 make numbered backups
  existing, nil   numbered if numbered backups exist, simple otherwise
  simple, never   always make simple backups
Report mv bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'mv invocation'

Philippe.

avant:

ipkg install findutils
et
ipkg install coreutils
Avant de poser votre question, pensez à vérifier si vos disques se trouvent dans la liste de compatibilité
- Besoin d'aide?
- Plugmedia [Alternative de la station multimedia]

#7 davelboss

    Qnapeur fidèle

  • Membres
  • PipPip
  • 20 messages
  • Matériel: TS-119

Posté 17 janvier 2012 - 10:27

Ok merci, je vous tiens informés.

#8 davelboss

    Qnapeur fidèle

  • Membres
  • PipPip
  • 20 messages
  • Matériel: TS-119

Posté 02 février 2012 - 22:07

Ok j'ai bien installé les packets IPKG en question. Cependant, comment se fait il qu'il existe un différence lorsque je saisi la commande suivante lorsque je suis dans:
~] # mv --help
BusyBox v1.01 (2011.11.11-20:46+0000) multi-call binary

Usage: mv [OPTION]... SOURCE DEST
or: mv [OPTION]... SOURCE... DIRECTORY

Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

Options:
-f don't prompt before overwriting
-i interactive, prompt before overwrite

Et lorsque je suis dans /opt/bin/

~] # /opt/bin/mv --help
Usage: /opt/bin/mv [OPTION]... [-T] SOURCE DEST
or: /opt/bin/mv [OPTION]... SOURCE... DIRECTORY
or: /opt/bin/mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options too.
--backup[=CONTROL] make a backup of each existing destination file
-b like --backup but does not accept an argument
-f, --force do not prompt before overwriting
-i, --interactive prompt before overwrite
-n, --no-clobber do not overwrite an existing file
If you specify more than one of -i, -f, -n, only the final one takes effect.
--strip-trailing-slashes remove any trailing slashes from each SOURCE
argument
-S, --suffix=SUFFIX override the usual backup suffix
-t, --target-directory=DIRECTORY move all SOURCE arguments into DIRECTORY
-T, --no-target-directory treat DEST as a normal file
-u, --update move only when the SOURCE file is newer
than the destination file or when the
destination file is missing
-v, --verbose explain what is being done
--help display this help and exit
--version output version information and exit

The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable. Here are the values:

none, off never make backups (even if --backup is given)
numbered, t make numbered backups
existing, nil numbered if numbered backups exist, simple otherwise
simple, never always make simple backups

Report mv bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'mv invocation'
[~] #
Le wiki qnap n'en parle pas... dois je lancer la commande depuis ce dossier pour avoir l'ensemble des fonctionnalités? puis je par défaut utiliser les commandes complète sans avoir à passer par ce dossier??
Je ne trouve pas l'info sur le net et n'ayant pas une culture linuxiène développée votre aide serait appréciée pour assouvir ma curiosité :)
Merci d'avance

Modifié par davelboss, 02 février 2012 - 22:10 .


#9 father_mande

    Qnapeur officiel

  • Administrateurs
  • 3 243 messages
  • Matériel: TS-459 Pro, TS-219, TS-109 II

Posté 03 février 2012 - 10:10

Bonjour,

En résumé, les Linux (embarqués) sont allégés car doivent "rentrer" en mémoire flash limitée ... puis transféré en mémoire vive (pour permettre entre autre la mise en sommeil des disques)
Pour ce faire elle utilise un "couteau suisse" qui est Busybox, un seul programme pour n programmes autonomes habituellement, bien sur si busybox est plus "léger" c'est qu'il communalise des fonctions utiles pour tous les indépendants et qu'il propose une version minimum incomplète mais suffisante en usage basique des commandes indépendantes ...

Ipkg ... lui propose les versions complètes de chaque utilitaire ...
le mv inclus ... pointe sur le module mv intégré à busybox
le mv ipkg ... est la version complète de mv ...

Si vous entrez mv (tout court) ... ce sera le premier trouvé dans le PATH (chemin de recherche des exécutables faites un echo $PATH pour le voir)
celui en interne est dans /bin ... donc c'est celui-ci qui est lancé ...
Le mieux est TOUJOURS d'utiliser le chemin complet (dans ce cas pas d'usage de PATH )
/bin/mv ... sera celui inclus
//opt/bin/mv ... sera le complet ...
la syntaxe "chemin complet vers l’exécutable" fonctionne, et va vers le bon exécutable, quelque soit l'endroit (répertoire) ou vous vous trouvez ...

Philippe.
QNAP TS-459, 3.6.0, Virtualbox, OpenVPN
QNAP TS-109, Debian Squeeze
QNAP TS-219P II, 3.6.1
La théorie, c’est quand on sait tout et que rien ne fonctionne. La pratique, c’est quand tout fonctionne et que personne ne sait pourquoi.
Le Raid N'EST PAS un backup (proverbe Qnapien)

#10 davelboss

    Qnapeur fidèle

  • Membres
  • PipPip
  • 20 messages
  • Matériel: TS-119

Posté 03 février 2012 - 10:49

Merci pour cette réponse détaillée, claire, et précise. :)





1 utilisateur(s) li(sen)t ce sujet

0 membre(s), 1 invité(s), 0 utilisateur(s) anonyme(s)