Montag, 30. Mai 2016

Linux Bash: Force writing console output to a file

Sometimes this command just does not write content to a file by the ">" operator:

myprogram do --something > my-file-with-the-output.txt

Then you can you a small Linux default program called "tee". Example usage:

myprogram do --something | tee my-file-with-the-output.txt

Tee allows you also to use some option as "-a" to extend the file's content's instead of replacing them.

Freitag, 27. Mai 2016

Git: Delete a remote branch

By specifying "origin" and "--delete" as parameters according to the branch name (e.g. "feature/1234_my_ticket), you can delete the remote branch. The working Git command looks like this:

git push origin --delete my_name/1234_my_ticket_id

Donnerstag, 26. Mai 2016

Apache2 RewriteRule: Map images folder from remote system to your local virtual host

With the following directive in your Apache2 virtual host file (at /etc/apache2/sites-available) you must not download the images from products etc. on your local system for development. You just map your local folder location to the remote one. The following example is for a Drupal site (files are under /sites/default/files):

RewriteEngine On
RewriteOptions Inherit
RewriteRule /sites/default/files/(.*)\.(jpeg|jpg|gif|png)$ http://www.my-website.com/sites/default/files/$1.$2 [L,R=301]

Montag, 23. Mai 2016

SFTP: Upload and download files from command line

Download one file:

sftp user@host:/path/to/file.txt localfile.txt
Upload one file:

scp localfile.zip user@host:/my/folder/