In a Bash script, is it possible to run a command in a specific folder? For example, I’d like to create a script that prints the contents of the /home folder using ls, no matter which directory the script is saved in.
In a Bash script, is it possible to run a command in a specific
Share
Actually, you can use
cdto change directory in a script (but it’ll not affect its parent shell). TryIt’ll print current directory (which is
/home) and list the content of it. No matter what location ofmyscript.shis.