Skip to content
Advertisement

Find all files with specific name and move it two levels up from its location

I want to find all files with specific name “stdout.1.0”, move it two/three levels up from its location. While moving it two/three levels up, I also want to rename it to “testjob.out”.

All “stdout.1.0” files are located six levels down from parent directory.

JavaScript

I used:

JavaScript

and it outputs:

JavaScript

The directories above is just representative of where the file is, but there are multiple “stdout.1.0” files starting three levels down from parent directory.

Advertisement

Answer

Here is a method in plain bash using globstar shell option , without using the find:

JavaScript

Drop the echo if output looks fine.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement