I am writing a script to remove files from directories (if given). When it is run without command line arguments it works in the current directory. When it is run with at least one command line argument it assumes that the 1st argument points (by relative or absolute pathname) to a directory to work in.
I am wanting to design it where the user would type in the script like this:
./script.sh /home
where this would change to the home directory.
Here's what I have:
#!/bin/bash
cd $1
I am new to shell scripting so any help is appreciated!
cd "$1"), there's not much else to say yet.cdcommand applies to the shell in which it is executed, in this case a non-interactive shell that executes the script. When the script completes and that shell exists, you are back in the shell from which you executed the script, and that working directory has not changed.rm -fr /carefully/vetted/pathname.