You can use a shell wildcard to match the set of files in question:
cp -p data_*.mat /dest/
You can use rsync
if you insist but based on your description and use it may be the wrong tool:
rsync -a data_*.mat /dest/
In both cases the shell (not the command) expands data_*.mat
to a list of all files/directories that match, leaving it unchanged if there are no matches. (The *
wildcard matches zero or more characters; ?
would match precisely one character.)
If your 1..n
is a subset of the possible matches it's a little harder but not much. Some shells (including bash
) allow a brace expansion for a fixed range: {1..27}
for example. Plug that in to the pattern and you have another solution:
cp -p data_{1..27}.mat /dest/
Remember that when you are using wildcard patterns, it's the shell that expands them, so there's no reason why you can't drop them into a command that starts with echo
just to see what's going to happen:
echo data_?.mat
echo rsync -a data_*.mat /dest/
echo cp -p data_{1..27}.mat /dest/