Site icon SEREK DEV

Dev notes

A collection of common commands usefull from developer perspective.

Bash

Fixing encoding to unix format on all files e.g. “*.sh”

Bash
find . -type f -name "*.sh" -exec dos2unix {} +
Bash

Calculating directory size in human readable format

Bash
du -sh directory/
#  79G    directory/
Bash

Copy directory via ssh recursively

Bash
scp user@s*.mydevil.net:/home/files /local/dir
Bash

Replace text in file

Bash
sed -i 's/old_text/new_text/g' /path/to/your/file

# for example 
sed -i 's/CREATE TABLE/CREATE TABLE IF NOT EXISTS/g' dump.sql
Bash

Adding text in the beggining and at the end

Bash
sed -i '1i Start of file' dump.sql
echo 'End of file' >> dump.sql
Bash

PHP Storm

Mysql Dump

In order to use MySql dump – add path in your DB configuration:

Bash
\\wsl.localhost\Ubuntu\usr\bin\mysqldump
Bash

Git

Modify last commit date

In order to modify last commit date we can use ammend with date function:

Bash
git commit --amend --date="$(date -d 'yesterday 23:00' -R)" --no-edit
Bash
Exit mobile version