1. Direct the output of the statement to file1.sql
unload to file1.sql
select name from sysmaster:sysdatabases where name not in ('sysmaster','sysutils','sysusers');
2. Prefix drop syntax
sed 's/^/drop database /' file1.sql > file2.sql
3. Substitute | with ;
sed 's/|$/;/' file2.sql > file3.sql
4. Review the statements (destructive in nature, be careful!) and execute it.
dbaccess - file3.sql