I would like to use sed to delete and replace some characters in a bash script.
#!/bin/bash
DIR="."
file_extension=".mkv|.avi|.mp4"
files= `find $DIR -maxdepth 1 -type f -regex ".*\.\(mkv\|avi\|mp4\)" -printf "%f\n"`
In order to simplify $files, I would like to use $file_extension in it, i.e. change .mkv|.avi|.mp4 to mkv\|avi\|mp4
How can I do that with sed ? Or maybe an easier alternative ?
files=( "$DIR"/*.{mkv,avi,mp4} )instead. Storingfind's output in a scalar variable is not a good idea, especially when there is no need to use it at all.