0

I have few files, having files name in the below form:

export_<directory_name>_system.indexes .json 

Here the directory keeps changing,so it could be anything

However _system.indexes is constant

Notice the space between 'indexes and '.json'.

I want to get rid of the space in between them, so the expected file name is as below

export_<directory_name>_system.indexes.json

I have tried the below:

echo export_direcotoryName_system.indexes .json | sed 's/\s\+//'

All though it does remove the space..but it also removes space from other files which i do not want.

How can restrict the removal only to files having system.indexes in their filenames

  • Possible duplicate of [Linux - Replacing spaces in the file names](https://stackoverflow.com/questions/1806868/linux-replacing-spaces-in-the-file-names) – Lee HoYo Jul 01 '18 at 00:22

1 Answers1

1

With prename:

prename -n 's/system.indexes .json/system.indexes.json/' *.json

if everythink looks fine, remove -n.

Cyrus
  • 84,225
  • 14
  • 89
  • 153