Skip to content

Instantly share code, notes, and snippets.

@Nodws

Nodws/Add prefix or suffix

Last active Jul 18, 2019
Embed
What would you like to do?
Find-Replace string in file's name
#add prefix
rename s/'^'/'MyPrefix'/ *
#add suffix
rename s/'$'/'MySuffix'/ *
#numbered
n=1; for f in ./*.jpg; do mv "$f" $n.jpg; n=$((n+1)); done
find . -type f -printf "%C@ %p\n" | sort -rn | head -n 10
// remove thumbs
find ./ \( -name '*x[0-9][0-9][0-9][0-9].*' -o -name '*x[0-9][0-9][0-9].*' -o -name '*x[0-9][0-9].*' \) -delete
find . -name '*.php' -exec grep -Hn 'SEARCHSTRING' '{}' \
grep --include=\*.{php,php6} -rnw './' -ie "SEARCH"
rename s/"SEARCH"/"REPLACE"/g *
//Replace Text
replace "old_string" "new_string" -- *.php
//Replace with regex
sed -i -- "s/<text .*svg>/<svg>/g" **.svg
//Find text in files
grep --include=\*.{php,php5} -rnw './' -e "NEEDLE"
//Chmod files and dirs
find /path/to/base/dir -type d -print0 | xargs -0 chmod 755
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644
@Nodws

This comment has been minimized.

Copy link
Owner Author

@Nodws Nodws commented Mar 22, 2019

Check disk space

sudo apt-get install ncdu
cd /
ncdu

Change /var/www

  1. Create symlink in /var/ to mounted dir
  2. Options in apache2.conf (AllowOverride All Require all granted)
  3. ServerName in sites_available/default.conf
  4. APACHE_RUN_USER in /envvars
  5. sudo service apache2 restart
@Nodws

This comment has been minimized.

Copy link
Owner Author

@Nodws Nodws commented Jul 18, 2019

Root user

sudo mysql -u root
SELECT User,Host FROM mysql.user;
DROP USER 'root'@'localhost';
CREATE USER 'root'@'%' IDENTIFIED BY 'pass';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment