Background
In Linux you can:
- List a group of files with
ls Filename*
- Remove a group of files with
rm Filename*
- Move a group of files with
mv Filename* /New/Directory
- But you cannot copy a group of files with:
cp Filename* *.bak
Change Linux cp
command to copy group of files
I have a group of files I'd like to copy without entering the names one by one and using the cp
command:
$ ls gmail-meta3*
gmail-meta3 gmail-meta3-REC-1558392194-26467821
gmail-meta3-LAB-1558392194-26467821 gmail-meta3-YAD-1558392194-26467821
How can I use something like the old DOS command copy gmail-meta3* *.bak
?
I don't want to type similar command four times:
cp gmail-meta3-LAB-1558392194-26467821 gmail-meta3-LAB-1558392194-26467821.bak
I'm looking for a script/function/app that accepts parameters for old and new filename group and not something with hard-coded filenames. For example, a user can type:
copy gmail-meta3* *.bak
or they might type:
copy gmail-meta3* save-*
touch aa ab ba; mkdir bb; cp a* b*; ls *
– Mike S Jun 27 '19 at 02:11*
for the source filenames but not for the target filenames. As such as substitute wildcard (I think##
was suggested but I'm leaning towards%
) will have to be used for the target. I think this is what you are reinforcing? I didn't expect to change thecp
command at all. Just create a wrapper script calledcopy
that emulated (within reason) the DOS copy command. – WinEunuuchs2Unix Jun 27 '19 at 02:27