-2

I've tried lots and lots of variations using the rename command in the Linux command line and nothing happens when I execute these commands - no errors and no expected outcomes. I've tried using the find command to find files and then rename them with no success. I have files that look like this

201901.cdas1.20190101.pgrbh.grb2flxf06.grb2
201902.cdas1.20190102.pgrbh.grb2flxf06.grb2 

and I need them to look like this for the script that is expecting a specific file name format 201901.flxf06.grb2 and 201902.flxf06.grb2.

I need to delete the middle part of the file name with a wild card since there are dates that change in multiple files. The deleted part is this: cdas1.pgrbh.grb2

this is not homework and I've been searching the internet most of the day trying to use different options other than the rename option or a for loop since I get a missing } braces error. Thank you!

Barmar
  • 741,623
  • 53
  • 500
  • 612
user2100039
  • 1,280
  • 2
  • 16
  • 31
  • `var=201901.cdas1.20190101.pgrbh.grb2flxf06.grb2;echo "${var/cdas1*.pgrbh.grb2}"` produces `201901.flxf06.grb2` . Good luck. – shellter Oct 31 '19 at 01:20

1 Answers1

0

Assuming you're using the perl rename command:

rename 's/cdas1\.pgrbh\.grb2//' *.cdas1.20190101.pgrbh.grb2*.grb2
Barmar
  • 741,623
  • 53
  • 500
  • 612