An alias is expanded simply by replacing the alias by its definition (as a list of tokens, not a string, which is basically equivalent to taking the string and adding a space at the end). So stopdev; true
is expanded to
cd $HOME/website; make website_stop; make backend_stop; ; true
^^^
Since you can't have two consecutive semicolons in the shell syntax, that's a syntax error.
You can remove the ;
, and that will make stopdev; startev
work, but it isn't good, because any argument you pass to stopdev
will be passed to make backend_stop
, which is probably not desirable.
You should make this a function. Also, don't run the make
commands if the cd
command fails.
stopdev () {
cd "$HOME/website" && {
make website_stop
make backend_stop
}
}
An improvement would be to make the function return a failure code even if make website_stop
fails but make backend_stop
succeeds.
stopdev () {
cd "$HOME/website" && {
make website_stop
ret=$?
make backend_stop && return $ret
}
}
Note that this leaves you in the ~/website
directory. To avoid changing the directory of the shell process, run the function in a subshell.
stopdev () (
cd "$HOME/website" && {
make website_stop
ret=$?
make backend_stop && return $ret
}
)
Alternatively, with GNU make, you can use its -C
option.
stopdev () {
make -C "$HOME/website" website_stop
ret=$?
make -C "$HOME/website" backend_stop && return $ret
}
If the targets never fail, just pass them both.
stopdev () (
cd "$HOME/website" && make website_stop backend_stop
)
or
stopdev () {
make -C "$HOME/website" website_stop backend_stop
}
- Either the
do
should appear on a new line, or it needs to have a semi-colon inserted in front of it
<FIRST-LAST>
should actually be the name of a shell variable, and FIRST-LAST
should be a reference to that variable. <
and >
are not legal characters for shell variables, so we can deduce that something else must be substituted here instead. person
seems to be as good a variable name as any in this particular case.
I think something like this should work much better:
while read person ; do
echo "${person}"
curl -O "https://www.uoguelph.ca/arts/history/people/${person}"
done < formatted_history.txt
This assumes that the file formatted_history.txt
actually exists in the current directory and is a list of people from the https://www.uoguelph.ca/arts/history/people/ page - something like:
tara-abraham
donna-andrew
susan-armstrong-reid
... etc ...
Best Answer
You should avoid setting the
PATH
variable. This is used by your shell to find valid commands, setting it to/tmp/
is going to prevent the script from being able to find therm
andcp
commands altogether.You can accomplish what you want with the following
find
command:Note: this will delete any subdirectories under /tmp as well. If you do not want this you must change to:
Another note: This will still recurse into the subdirectories and delete the files in them. If you do not want this you can use the
maxdepth
argument:Extra note: I would never run a
find ... -exec
command that you find online without verifying it will do what you need it to do first. You should run:And verify it is finding only the files you want before adding the
-exec rm -vr {} \;
bit.