A linux command I have outputs a list of files that look like this:
folder/folder/folder/file_1
folder_1/folder/folder/file2
I want to format this output so the following conditions are met:
- The last slash (/) is always replaced with three underscores
- Every slash except the last slash is replaced with one underscore
- Any underscore in a folder name is replaced with two underscores
- Any underscore in a filename is left the way it is
The above would look like:
folder_folder_folder___file_1
folder__1_folder_folder___file2
If you could also explain your solution that would be helpful. Thanks!
1 Answer