I have a script for school that mimics the cp command. Part of the assignment is to modify the script so that the
while loop (that assigns
stdin to the variable
filelist) is instead done with sed.
The last argument needs to be saved to the variable
to because that could be a directory depending on other user input in the script.
while [ "$#" -gt 1 ] do filelist="$filelist $1" shift done to="$1"
Is this finished product good? How could I polish it up?
filelist=$(echo $* | sed 's/ [^ ]*$//') to=$(echo $* | sed 's/^.* \([^ ]*\)$/\1/')