touch ~/deleted/$(echo "directory_"$(readlink -f foo)|tr '/' '\') 2> /dev/null
where foo is a directory
It's reading the full pathname of foo and creating it as a file replacing all '/' with '\' and putting a directory_ in front so the directory
/home/test/foo
would create a file directory_\home\test\foo
It does exactly what I want except a warning keeps printing tr: warning: an unescaped backslash at end of string is not portable
a. I don't know what that means b. I would like it to not show
I tried to redirect stderr to /dev/null
but it doesn't work. How do I suppress it?
$1
defined? You should also be aware that while\
are allowed in file names, it is a Very Bad Idea® to include them and it will lead to all sorts of trouble later on.\
, backslashes are special as you're finding out.