Can't use temp dir

83 Views Asked by At

I'm trying to make tmp dir with bash script using that command:

mktemp -d /tmp/foo.XXXXXXXXX\r

So, as an result a have, for example (with common in the end):

/tmp/foo.wGBkCRpYt.

But I can't change dir after that from this bash script:

cd /tmp/foo.wGBkCRpYt 

Answer: No such file or directory

cd /tmp/foo.wGBkCRpYt. 

Answer: No such file or directory

What's wrong I do?

1

There are 1 best solutions below

0
On

The first line of your example ends with r, while the rest of your examples end with . (dot, period, full stop). Perhaps if they all matched, it would work.

Tested on Debian 11:

This works for me:

$ mktemp -d /tmp/foo.XXXXXXXXX\r
/tmp/foo.HaOsouwEHr
$ cd /tmp/foo.HaOsouwEHr
$ pwd
/tmp/foo.HaOsouwEHr
$

This works for me:

$ mktemp -d /tmp/foo.XXXXXXXXX.
/tmp/foo.H8ERdkgtV.
$ cd /tmp/foo.H8ERdkgtV.
$ pwd
/tmp/foo.H8ERdkgtV.
$