I'm trying to write a script that removes temporary files (ie. files with a tilde at the end: temp.txt~)
#!/usr/bin/ruby system("rm *~") if File::exists?( "*~" );
but that literally looks for files named *~.
I tried something like this:
#!/usr/bin/ruby if File::exists?( /\w*~/ ) puts "Temp exists\n"; else puts "Temp doesn't exist\n"; end
but that gives me this:
in `exists?': can't convert Regexp into String (TypeError)
How should I correctly search and remove these files?