You can use the special
# ls /usr/pkgsrc
# cd $_
netbsdnoob how do i source a file with .sh? I had a file with some variables set and i tried "source script.sh", ". script.sh", "sh script.sh" but none of them worked.
Using the built-in
. (dot) command.
Any good cheatsheet of keyboard shortcuts for sh?
Yes, the man page; if you search for
source inside sh(1), you immediately get to:
The dot command reads and executes the commands from the specified
file in the current shell environment. The file does not need to
be executable and is looked up from the directories listed in the
PATH variable if its name does not contain a directory separator
(‘/’). The return command (see below) can be used for a premature
return from the sourced file.
nettester Can you give a bit more details why it doesn't work? I don't see why sourcing a file wouldn't work in ksh/sh.
source is not POSIX;
. (dot) instead is standardized (at least since 1003.1, 2004).