1


I failed to accesses "user entry" by shell script, the following commands interrupt errors ( ls: cannot access '~/Workspace': No such file or directory )

ls ~/Workspace
ls "~/Workspace"
ls "\~/Workspace"

commanding the above via terminal works fine. any ideas?
I'm using fedora 25 without significant customization. thanks.

3
  • How are you executing the script and do you have #!/bin/bash at the top of the script? Commented May 5, 2017 at 9:32
  • Have you tried using $HOME variable instead of the ~ ? Commented May 5, 2017 at 10:04
  • Tilde expansion should work in noninteractive shells too, I don't see anything obviously wrong with the first example. The second two would not work because the tilde is quoted. Commented May 5, 2017 at 12:50

1 Answer 1

1

Are you sure the "Workspace" dir exist on home dir for that user?

Anyway, try this:

#!/bin/bash
ls $HOME/Workspace
Sign up to request clarification or add additional context in comments.

1 Comment

Ok, mark it as solved please. Maybe could be useful for others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.