What four ways can you specify the current directory in your PATH? for sh

This is a question that I couldn't get it right. I thought pwd is one of the way but it wasn't.

can anyone help? thanks

Well what way(s) did you figure out so far, so we don't duplicate all the simple ones you know about so far.

Well what way(s) did you figure out so far, so we don't duplicate all the simple ones you know about so far.

actually, I don't quite get what it is actually questioning. I think it is asking how I should print out my current directory???

I had my answer pwd, cd . ,,, can you explain what the question actually means? and post the possible answers?

What this question means is "What can you specify in your PATH environment variable which wil allow you to run scripts in the current directory."

For instance, my default PATH variable is:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games

omrsafetyo@kulas-net:~$ echo "echo it worked" > script1
omrsafetyo@kulas-net:~$ script1
bash: script1: command not found

But, if I specify:

PATH="${PATH}:."

(PATH colon dot)

I can now run script locally:

omrsafetyo@kulas-net:~$ script1
it worked

I don't have to specify "./script1" to run my local script - because it is now in my path.

Another would be "${PWD}"
PWD is an environment variable which specified the current directory at any time - adding that to the PATH makes the current directory part of your executable path.

Another, making this a trick question is a null word. e.g.:
PATH="${PATH}:"
(PATH equals PATH colon)

omrsafetyo@kulas-net:~$ PATH="${PATH}:"
omrsafetyo@kulas-net:~$ script1
it worked

So whats the fourth way?

:D

alright, if no one else is going to spill it, method 4 is "echo pwd"

1. PATH="${PATH}:echo pwd"  # echo pwd
2. PATH="${PATH}:"    # null
3. PATH="${PATH}:."  # dot
4. PATH="${PATH}:${PWD}" #$PWD
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.