0

Bash Script: Each file inside table directories will need be renamed from keyspace to newkyespace_456 when it is copied to destination.

└── Main_folder
    ├── keyspace
    │   ├── tableA-12323/keyspace-tableA-12323-ka-1-Data.db
    │   ├── tableB-123425/keyspace-tableA-123425-ka-1-Data.db
    │   └── tableC-12342/keyspace-tableA-12342-ka-1-Data.db
    └── newkeyspace_456 ( given folder) and sub folders
        ├── tableA-12523 
        ├── tableB-173425
        └── tableC-1242

Example is keyspace/tableA-12323/keyspace-tableA-12323-ka-1-Data.db to newkeyspace_456/tableA-12523/newkeyspace_456-tableA-12523-ka-1-Data.db

Note that same table (Type A , B , C) type can be copied to same table type in other keyspaces (Type A , B , C) . The table name also need changes in file name , please note in example 12323 has been renamed to 12523 when copied to diretory newkeyspace_456/tableA-12523.

Type A table files can be copied from keyspace/tableA-12323 to Type A table files in newkeyspace_456/tableA-12523.

How do I approach this problem?

Thanks tom

1 Answer 1

1

Use parameter expansion with string substitution for changing filename, like this:

for fn in $(find ./keyspace -path '*.db') ; do cp "$fn" "${fn//keyspace/newkeyspace_456}" ; done ;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.