notegrep: "sc" parameter

This commit is contained in:
dmarakom6 2021-06-23 17:51:16 +03:00
parent 414e12f7fa
commit 45dc8e6bd7
2 changed files with 28 additions and 5 deletions

View file

@ -122,8 +122,8 @@ function notegrep() {
check_params() {
case $option in
parameter)
#parameter script import...
-sc)
. ~/.shellnotes/util/notegrep/sc.sh
;;
*)
echo "Invalid parameter. Proceeding in normal grep mode."
@ -132,6 +132,7 @@ function notegrep() {
esac
return 0
}
if [ $# -eq 0 ]; then
@ -139,9 +140,9 @@ function notegrep() {
echo -n "Enter note name: " && read notename
else
if [ $# -eq 3 ]; then
option=$1
regex=$2
notename=$3
export option=$1
export regex=$2
export notename=$3
check_params
return 0
else

22
util/notegrep/sc.sh Normal file
View file

@ -0,0 +1,22 @@
:<<'info'
shellnotes - sc.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
:<<'vars'
Used from main file:
$option
$regex
$notename
vars
out="$(cat $DEFAULT_PATH/$notename | sed s/$regex/\\n/g | wc -l)"
if [ $out -gt 20 ]; then
cat $DEFAULT_PATH/$notename | sed s/$regex/\\n/g | less
elif [ $out -le 20 ]; then
cat $DEFAULT_PATH/$notename | sed s/$regex/\\n/g
fi