Last active
July 18, 2019 16:39
-
-
Save Nodws/6123591 to your computer and use it in GitHub Desktop.
Find-Replace string in file's name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -name '*.php' -exec grep -Hn 'SEARCHSTRING' '{}' \ | |
grep --include=\*.{php,php6} -rnw './' -ie "SEARCH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
Check disk space
sudo apt-get install ncdu
cd /
ncdu
Change /var/www