Help please!
I have a set of 60 files named in the following format:
and I would like to remove the "_L2" part and everything else after the third underscore, in order to have something like:
The number "XXXXX" varies between the files, and for each number there is always a R1 file and a R2 file.
Maybe a rename or a sed command can help.
Thanks!
Using rename
utility you can do this:
rename -n 's/^([^_]+)_L2(_[^_]+)[^.]+(\..+)$/$1$2$3/' *.gz
Once satisfied with dry run remove -n
option and rerun.