fork download
  1. #!/bin/bash
  2. path="/path/to/file 20-456 (1).jpg"
  3. fldr="${path%/*}" # Get the folder
  4. file="${path##*/}" # Get the file name
  5. file="${file// /_}" # Replace spaces with underscores in filename
  6. echo "$fldr/${file//[^[:alnum:]._-]/}" # Get the result
  7.  
Success #stdin #stdout 0.01s 5504KB
stdin
Standard input is empty
stdout
/path/to/file_20-456_1.jpg