Unix tools

grep, find

Find files with a specific extension: find . | grep -i "\.tex"

Find directories:

find . \( -type d \)

Find and remove directories:

find . \( -type d \) -exec rm -r {} \;

grep options:

-i case insensitive

-n show line numbers

Example: grep -ni "what I'm looking for" my_file.txt

Symbolic link

Use ln -s <file or directory> .

To remove, use rm <file> or rm <directory without the trailing />

unrar

unrar x file.rar

Extracts files from file.rar, including the path stored in file.rar

unrar t file.rar

Tests the archive, printing the content of file.rar to standard output.

ffmpeg

-v 3 (verbosity)

-i <input filename>

-b:v 1024k (bitrate, bit/s)

-bt 1024k (bitrate tolerance in bits)

-qscale:v 4 (The avail­able qscale val­ues range from 1 (high­est qual­ity) to 31 (low­est qual­ity))

-strict -2 (to use the experimental mp4 h264 encoder)

ffmpeg -i <frames-in>_%04d.png -b:v 1024K <video-out>.mp4

ffmpeg -i <video-in>.wmv -b:v 1024K -qscale:v 4 -strict -2 <video-out>.mp4

Converting to png:

ffmpeg -v 1 -i 'myvideo.mp4' 'myimages_%04d.png'

How to compress a pdf document?

Wether you are working on a Mac (MacOSX), on Windows or Linux, you might want to compress existing pdf files to reduce its file size. Use Ghostscript :

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=out.pdf in.pdf

-dPDFSETTINGS=/screen = 72 dpi images

-dPDFSETTINGS=/ebook = 150 dpi images

-dPDFSETTINGS=/printer = 300 dpi images

-dPDFSETTINGS=/default

subversion

Common commands:

svn commit

svn update

svn diff -r<revision number> <file>

svn update -r<revision number> <file>

svn add <file>

svn delete <file>

svn move <file before> <file after>

svn info <file>@<revision number>

svn help

svn propedit svn:ignore ./some_path (./ for example), then in the editor, add things like *.class, *.obj, etc. one per line.

svn checkout <your repository url> <directory where to put the files>

optional: --username <your user name>

Git

Git for those who know subversion: http://git.or.cz/course/svn.html

Advice: pull frequently (avoids complex conflict resolution); commit often, commit when changes have been tested.

It is useful to first understand the different states that a file can be into: https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository

Works with the hosted repository:

git clone git://<host>/project.git

git pull

git push -u origin master (-u saves the parameters remote 'origin' and the branch 'master')

git push

git reset <filename> (reset a staged file)

git checkout -- octocat.txt

Works with the local repository:

git add

git commit

git rm (removes files on disk and stages it)

git commit -a : Removes files that are no longer on disk. This is an alternative to git rm.

Branches:

git branch <branch name>

git checkout <branch name>

git merge <branch name> (you need to be in the 'parent' branch, for example in the master branch, so git checkout <parent branch>, then git merge <child branch>, and you then need to push your changes, for example with git push origin master

git branch -d <branch name> : deletes the branch

Common commands:

git diff

git diff --staged (diff files not commited yet)

git config --global diff.tool <the software you want to use>

git blame (-w ingnore white space -M ignore moving text) : identifies who modified a line.

Other commands:

git status

git log

git init (in the repository where you want to initialize a repository)

git stash (save current changes to get back to a clean repository)

git stash pop (get back to the save changes)

git stash drop (forget these savec changes)

CVS

You added a file as text while it is a binary file? Change it from text mode to binary right inside CVS:

cvs admin -kb yourfile.jpg

cvs update -A yourfile.jpg

Change the command to cvs admin -kkv yourfile.txt to do the inverse modification (binary to ascii). You still need to do cvs update -A yourfile.txt.

Emacs, XEmacs, Aquamacs

Split screen horizontally (C-x 2) or vertically (C-x 3).

Tar

Parallel compression of files using multi-core CPUs:

tar --use-compress-program=pbzip2 -cvf test-2-frames.tar.bz2 test-frames