-3

How can I copy the name of *.mkv to poster.jpg in bash using wild cards.

Thanks

Dvae
  • 1
  • 1
  • 1
    welcome to SO... what did you try? how did it fail? give examples... read https://stackoverflow.com/help/how-to-ask and https://stackoverflow.com/help/mcve – Sundeep Jul 13 '17 at 13:54
  • This Q is not about programming as defined for StackOverflow. It **may** be more appropriate on http://superuser.com or another StackExchange site. Use the `flag` link at the bottom of your Q and ask the moderator to move it. Please don't post the same Q on 2 different sites. ***Please*** read http://stackoverflow.com/help/how-to-ask http://stackoverflow.com/help/dont-ask and http://stackoverflow.com/help/mcve before posting more Qs here. Good luck. – shellter Jul 13 '17 at 14:01
  • Do you just want `cp *.mkv poster.jpg` (assuming that only one file will match)? – Tom Fenech Jul 13 '17 at 15:03

1 Answers1

0

If you want to match to files with *.mkv in the name, and for each file named <foo>.mkv, you want to create a foo.jpg, you can use regular expressions with parentheses around the parts of the regular expression you want to match, and then use ${BASH_REMATCH[n]} to access the n'th matched part of the regular expression and reuse it elsewhere. There's an example here: bash regex match string.

If you're trying to do something completely different from what I just described, it would probably be a good idea to make your question clearer.

anandsun
  • 186
  • 6