Search code examples
linuxbashscp

Copying all files in directory based on filename pattern match


I am new to linux commands use pattern matching. In my local folder, I have many .txt files with certain endings.

foobar_type01.txt
foobar_type02.txt
foobar_type03.txt
baz_type01.txt
baz_type02.txt
baz_type03.txt

My goal is to scp all of the files from my directory to a server that end with ...type03.txt so in this case only the following would be copied:

foobar_type03.txt
baz_type03.txt

What is the correct command to scp filename matches as opposed to extensions? All I have been able to do is use the extension pattern

scp -C -r  /my_folder/*.txt server@10.10.55.28:

Solution

  • scp -C -r /my_folder/*type03.txt server@10.10.55.28: