Reputation: 91
i'm trying to write script asking about file and directory and then copying file. I wanted to do something looking that way:
#!/bin/bash
read FILE
read DIRECTORY
cp $FILE $DIRECOTRY
file and directory i choose do exist, but script does not work despite returning no error.
Upvotes: 0
Views: 3405
Reputation: 3826
Try to fix a typo: cp "$FILE" "$DIRECTORY"
(""
are to allow filenames with whitespaces), and then you can run your script, enter the two names on two lines and see the result. You can also add -x
to see commands running. In full:
#!/bin/bash -x
read FILE
read DIRECTORY
cp "$FILE" "$DIRECTORY"
Upvotes: 2