Useful Linux/Programming Snippets – Wave 1

I’ve been keeping a list of things I’ve had to look up for school or work, programming wise, and I thought it might be helpful to list them here. It’s more of a reference than anything, and I know it helps me to look back on it if I forget something little, so maybe someone else will find it useful too.

to execute a premade .sql file
mysql -p -D databasename < file.sql

find/replace in Emacs (discriminately, that is: it will ask you at each instance if you want to replace)
M-x query-replace <ENTER>
oldstring <ENTER>
newstring <ENTER>

  •     space – replace
  •     n – skip
  •     enter – quit

cat a bunch of files together into one
cat file1 file2 > allfiles
cat file* > allfiles

to get unix time in bash
date +%s

to get unix time in mySQL
select UNIX_TIMESTAMP(now());

rename a table in mySQL
RENAME TABLE oldname TO newname;

I’ll probably add more as I find them.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s