I'm writing a bash script that prints the contents of a file called website
(using cat
) that is inside a folder with a space in it's name, for example folder 1
. but I can't make bash get the path correct, it always uses only the first word in the folder name, so cat folder/website
instead of cat folder 1/website
. so I want to replace the space with \
. I tried using sed
and tr
, but they didn't work.
here is my code:
function get-website() { DIR="$1" website="$(cat "main/apps/$DIR/website")" }
most of what I tried is here: Replace character X with character Y in a string with bash
thanks in advance!
get-website $2
instead ofget-website "$2"
. thanks a lot.