Skip to main content
1 of 2
user1794469
  • 4.2k
  • 1
  • 27
  • 42

You can do this with a one liner:

grep '^aaa.*\.png$' list.txt | xargs cp {} destination_dir/

grep is looking for 'aaa' at the start of the line followed by zero or more characters and ending with '.png'. It then pipes that as a list of arguments to cp which moves them to 'destination_dir'

user1794469
  • 4.2k
  • 1
  • 27
  • 42