Skip to main content
Tweeted twitter.com/StackUnix/status/1007308298301968384
edited title
Link
ilkkachu
  • 148k
  • 16
  • 268
  • 441

Rename a specific character Replace slashes in a Stringfilename

added 10 characters in body
Source Link
jesse_b
  • 41.6k
  • 14
  • 108
  • 163

So I need to write a bash script that copies all files to a specified directory however I need to rename the files to it's absolute path by replacing the // character with ____.

For example if the file zad1.shzad1.sh is in the directory /home/123456//home/123456/ the file needs to be renamed to __home__123456__zad1.sh__home__123456__zad1.sh

Any ideas on how to do this?

So I need to write a bash script that copies all files to a specified directory however I need to rename the files to it's absolute path by replacing the / character with __.

For example if the file zad1.sh is in the directory /home/123456/ the file needs to be renamed to __home__123456__zad1.sh

Any ideas on how to do this?

So I need to write a bash script that copies all files to a specified directory however I need to rename the files to it's absolute path by replacing the / character with __.

For example if the file zad1.sh is in the directory /home/123456/ the file needs to be renamed to __home__123456__zad1.sh

Any ideas on how to do this?

Source Link
David Mathers
  • 133
  • 1
  • 2
  • 8

Rename a specific character in a String

So I need to write a bash script that copies all files to a specified directory however I need to rename the files to it's absolute path by replacing the / character with __.

For example if the file zad1.sh is in the directory /home/123456/ the file needs to be renamed to __home__123456__zad1.sh

Any ideas on how to do this?