I'm trying to convert 2 command lines to work with bash but don't know how. And also make the bash script execute commands in the folder it's already in. This is about what it looks like right now. They work perfectly fine as command lines but not as bash commands.
#!/bin/bash
#Command that removes all files except the ones specified
cd folder1/folder2; rm -v !("file1"|"file2")
#Command that picks a random line from one file and makes another file with that line. But never the same one twice in a row.
grep -Fxv -f file1 /home/file2 | shuf -n 1 > tempfile; mv tempfile file1