If file contains an "_" (underscore), I would like to skip that file movement.
You could try this
find /abc/xyz -maxdepth 1 -type f ! -name '*_*' -exec mv {} /mno/pqr
! -name '*_*'
will skip all files which have a '_' in their names. If you have more than one illegal characters to check, you could add one test (such as! -name '*_*'
) for each of these characters.I would like to have a parameter flag, which when 0 or 1, would enable to overrite files with same name at the destination.
mv -n
do not overwrite an existing filemv -f
do not prompt before overwriting
Skip moving of files with illegal characters in Ubuntu system
-
19-10-2022 - |
Question
I'm moving some files in the Ubuntu system, which is currently moving all files with or without extension in a folder
Following is the command i'm using :
find /abc/xyz -maxdepth 1 -type f -exec mv {} /mno/pqr
But now I want to move files only after applying some filter :
- If file contains an "_" (underscore), I would like to skip that file movement.
- I would like to have a parameter flag, which when 0 or 1, would enable to overrite files with same name at the destination.
Can somebody please help me out ?
No correct solution
OTHER TIPS
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow