#!/bin/bash for filename in *; do if [[ -f "$filename" ]]; then base=${filename%.*} ext=${filename#$base.} mkdir -p "${ext}" mv "$filename" "${ext}" fi done
find . -name \*.txt -exec cp {} someDirectory \;
or
find . -name "file*" -exec mv {} /tmp \;
NOTE: The open brackets {} are a placeholder for the argument which is to be used from the output of find.
NOTE: Why not just use mv file* /tmp.