find & mv with xargs
by kzo81 from LinuxQuestions.org on (#6KKC4)
Hi Folks;
Could you help me with find and xargs? This is what I'm stuck with:
Code:#!/bin/sh
set -x
SRC='/media/sdmmc/mmcblk0p1/RECORD/'
EXPORT_FOLDER='/media/sdmmc/mmcblk0p1/RECORD/EXPORTS/'
mkdir -p "$EXPORT_FOLDER"
find "$SRC" -name "*.mkv" -mmin +1 -print0 | xargs -i {} mv {} $EXPORT_FOLDERfor some reason this is the error message:
Code:xargs: invalid option -- 'i'
BusyBox v1.22.1 (2014-07-03 15:30:22 CST) multi-call binary.
Usage: xargs [OPTIONS] [PROG ARGS]
Run PROG on every item given by stdin
-p Ask user whether to run each command
-r Don't run command if input is empty
-0 Input is separated by NUL characters
-t Print the command on stderr before execution
-e[STR] STR stops input processing
-n N Pass no more than N args to PROG
-s N Pass command line of no more than N bytes
-x Exit if size is exceededI was trying with this as well:
Code:+ find /media/sdmmc/mmcblk0p1/RECORD/ -name *.mkv -mmin +1 -print0
mv: can't stat '/media/sdmmc/mmcblk0p1/RECORD/M-20240325_104804_0002/2024-03-25__11_08_15.mkv/{}': Path has non-directory component
mv: can't stat '/media/sdmmc/mmcblk0p1/RECORD/M-20240325_104804_0002/2024-03-25__11_08_15.mkv/EXPORTS': Path has non-directory component
mv: can't stat '/media/sdmmc/mmcblk0p1/RECORD/M-20240325_104804_0002/2024-03-25__11_08_15.mkv/2024-03-25__10_58_10.mkv': Path has non-directory component
Could you help me with find and xargs? This is what I'm stuck with:
Code:#!/bin/sh
set -x
SRC='/media/sdmmc/mmcblk0p1/RECORD/'
EXPORT_FOLDER='/media/sdmmc/mmcblk0p1/RECORD/EXPORTS/'
mkdir -p "$EXPORT_FOLDER"
find "$SRC" -name "*.mkv" -mmin +1 -print0 | xargs -i {} mv {} $EXPORT_FOLDERfor some reason this is the error message:
Code:xargs: invalid option -- 'i'
BusyBox v1.22.1 (2014-07-03 15:30:22 CST) multi-call binary.
Usage: xargs [OPTIONS] [PROG ARGS]
Run PROG on every item given by stdin
-p Ask user whether to run each command
-r Don't run command if input is empty
-0 Input is separated by NUL characters
-t Print the command on stderr before execution
-e[STR] STR stops input processing
-n N Pass no more than N args to PROG
-s N Pass command line of no more than N bytes
-x Exit if size is exceededI was trying with this as well:
Code:+ find /media/sdmmc/mmcblk0p1/RECORD/ -name *.mkv -mmin +1 -print0
mv: can't stat '/media/sdmmc/mmcblk0p1/RECORD/M-20240325_104804_0002/2024-03-25__11_08_15.mkv/{}': Path has non-directory component
mv: can't stat '/media/sdmmc/mmcblk0p1/RECORD/M-20240325_104804_0002/2024-03-25__11_08_15.mkv/EXPORTS': Path has non-directory component
mv: can't stat '/media/sdmmc/mmcblk0p1/RECORD/M-20240325_104804_0002/2024-03-25__11_08_15.mkv/2024-03-25__10_58_10.mkv': Path has non-directory component