Last active
May 7, 2024 11:36
-
-
Save achesco/35d4e3cc67dc675acd51afb547ed7a43 to your computer and use it in GitHub Desktop.
Revisions
-
achesco revised this gist
Sep 14, 2018 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,9 @@ # self sign cert for localhost openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt # find folder which content's size less than 10kb find /volume1/Volume/fapfapbackup -mindepth 1 -maxdepth 1 -type d -exec du -ks {} + | awk '$1 <= 10' | cut -f 2- # Send output to Telegram, JSON POST with curl # telelog.sh LOG=`cat <&0` -
achesco revised this gist
Jun 8, 2018 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -30,6 +30,14 @@ while read line; do echo $value; done < "myfile" # Чтение токенов из строки # Reading tokens string while IFS=' ' read -ra ADDR; do for letter in "${ADDR[@]}"; do echo $letter; done done <<< "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" # Создать директорию если она не существует # Create folder if it’s does not exists if [-d /tmp/old]; then; elif; fi -
achesco revised this gist
Aug 22, 2017 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ # self sign cert for localhost openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt # Send output to Telegram, JSON POST with curl # telelog.sh LOG=`cat <&0` -
achesco renamed this gist
Aug 20, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
achesco revised this gist
Nov 24, 2016 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -90,3 +90,12 @@ netstat -lnp # Переименовать с префиксом # Batch rename with prefix for f in * ; do mv "$f" "PRE_$f" ; done # Найти битые ссылки на сайте # Find broken links for site wget --spider -e robots=off --wait 1 --recursive --level=8 -o wget.log -p https://www.site.com/ # --spider – используем HEAD запросы # -e robots=off – игнорируем инструкции robots.txt # --wait 1 – ждём 1 секунду между запросами # --recursive --level=8 – рекурсивно обходим в глубину на 8 уровней cat wget.log | grep -B 2 '404' -
achesco created this gist
Nov 18, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,92 @@ # Send output to Telegram, JSON POST with curl # telelog.sh LOG=`cat <&0` curl -H "Content-Type: application/json" \ -X POST -d '{"chat_id":"<num or @chat>","text":"'"$LOG"'"}' \ "https://api.telegram.org/bot<access token>/sendMessage" #usage cat file.log | telelog.sh # Format ls date, get columns ls -l --time-style iso folder | awk '{print $5, $6, $7, $8}' # Case by user input param case "$1" in "action") echo 'do action' ;; *) echo 'do default' ;; esac # Чтение файла построчно # Line by line file reading while read line; do value=`expr $value + 1`; echo $value; done < "myfile" # Создать директорию если она не существует # Create folder if it’s does not exists if [-d /tmp/old]; then; elif; fi # Разбиение на подстроки с разделителем # Split line by divider echo $string |cut -d';' -f1 | read str1 echo $string |cut -d';' -f2 | read str2 # Запуск команды или скрипта в фоне # Run in background command-name & # Запуск скрипта или команды работающего после логаута # Run command in background after logout nohup find / -xdev -type f -perm +u=s -print > out.txt 2>&1 & # Найти # Find # … и удалить / and remove (delete) find . -type f -name "FILE-TO-FIND" -exec rm -f {} \; # … Case Insensitive find . -iname PatTeRn -print # … с глубиной поиска / limti search depth find . -maxdepth 1 # Архивировать без сжатия, кусками по 100 мегабайт # Do archive without compression, split by parts zip -0 -s100mb -r archive.zip folder_to_archive # Поиск файла по содрежимому # Search file by contents find . -type f -exec grep -il "pattern" {} \; grep -il "pattern" `find . -type f` # для большого кол-ва файлов find . -type f | xargs grep -il "pattern" # Размер директории # Total directory size du -sh /path/to/folder; # Подсчет строк в файле # How to count lines in a file wc -l /path/to/file; # Использование памяти процессами # Memory usage per process ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'; # Найти все файлы по контенту # Find files by content grep -rn 'bindToDoc' ./bower_components/islands-components/*/popup/ # Найти все файлы с кириллическими символами в одинарных ковычках (локализация в коде) grep -rniEe "'.*[а-я]+.*'" ./blocks/ | grep -v i18n # Какой процесс слушает порт # Which process port used by netstat -lnp # Переименовать с префиксом # Batch rename with prefix for f in * ; do mv "$f" "PRE_$f" ; done