123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #!/bin/bash
- # Coding: utf-8
- # Editor: www.geany.org
- # Created 2016-12-24
- source $HOME/.SCR/lib.sh
- echo ""
- fun_echo_color 11 0 "Example: Move|Delete 19|15 16 10"
- echo ""
- read -p "Seeking words: " args
- echo ""
- num_args="$(echo "$args" | wc -w)"
- arg1="$(echo "$args" | awk -F" " '{ print $1}')"
- echo "$num_args $arg1"
- fun_echo_color 10 0 "Select folder to find files consist this lines:"
- echo ""
- echo "[1] .RES/txt"
- echo "[2] .RES/dvd"
- echo "[3] cloud"
- echo "[4] LOG"
- read ChoiceNamber
- case "$ChoiceNamber" in
- "1" )
- folder="$HOME/.RES/txt"
- option="-rhi"
- ;;
- "2" )
- folder="$HOME/.RES/dvd"
- option="-rn"
- ;;
- "3" )
- exit_cmd="y"
- until [ "$exit_cmd" == "$y" ]
- do
- echo ""
- fun_echo_color 10 0 "r. Print search results"
- fun_echo_color 10 0 "p. Print some file"
- fun_echo_color 10 0 "e. Exit"
- echo ""
- read ChoiceNamber
- case "$ChoiceNamber" in
- "r" ) egrep -riIn --include "*.txt" -A 2 --color=always "$arg1" "$HOME/cloud" | sed -e 's/\/home\/a\/cloud\///g'
- ;;
- "p" ) file="$(egrep -riInl --include "*.txt" "$arg1" "$HOME/cloud" | rofi -dmenu -width 90)"
- fun_echo_color 1 1 "*********************************************************************************************"
- cat "${file}"
- fun_echo_color 1 1 "*********************************************************************************************"
- ;;
- "e" ) exit 0
- ;;
- * ) fun_echo_color 10 0 "You choose ${ChoiceNamber}. May be r|p|e only"
- ;;
- esac
- done
- ;;
- "4" )
- folder="$HOME/LOG"
- option="-riI"
- ;;
- * )
- fun_echo_color 10 0 "You choose ${ChoiceNamber}. May be 1-4 only"
- exit 0
- ;;
- esac
- # -r выполняет рекурсивный поиск
- # -H вызывает печать имени файла (подразумевается при поиске нескольких файлов)
- # -I игнорировать двоичные файлы (дополнение: -a обрабатывать все файлы как текст)
- # -h не начинать вывод с имени файла
- # -i выполнить поиск без учета регистра
- # -n вызывает печать номера строки
- fun_find ()
- {
- egrep $option --color=always "$1" $folder | sort
- }
- if [ $num_args == "1" ];
- then
- fun_find "$arg1"
- exit 0
- fi
- arg2="$(echo "$args" | awk -F" " '{ print $2}')"
- if [ $num_args == "2" ];
- then
- fun_find "$arg1" | egrep "$arg2"
- exit 0
- fi
- arg3="$(echo "$args" | awk -F" " '{ print $3}')"
- if [ $num_args == "3" ];
- then
- fun_find "$arg1" | egrep "$arg2" | egrep "$arg3"
- exit 0
- fi
|