finish (maybe) script
This commit is contained in:
parent
c7c9b5d848
commit
8edddfd9ea
|
@ -13,15 +13,35 @@ searchfile() {
|
||||||
if echo $link | grep -E '^http' >/dev/null; then
|
if echo $link | grep -E '^http' >/dev/null; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if echo $link | grep -E ".md$" && find . -name "$link"; then
|
if [ $(find . -name "$link"".md" 2>/dev/null | wc -l) -gt 0 ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
if echo "$link" | grep "#" >/dev/null; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if echo "$link" | grep -Ev ".md$" >/dev/null; then
|
||||||
|
if ls "$link" 2>/dev/null >/dev/null; then
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
echo $link
|
||||||
|
FILES=$(find . -iname "*$(basename $link)*")
|
||||||
|
echo "$FILES" | cat --number
|
||||||
|
read PICK
|
||||||
|
FILE=$(echo "$FILES" | head -n $PICK | tail -n 1)
|
||||||
|
REPLACE=$(escape '('$link')')
|
||||||
|
REPLACEWITH=$(escapeReplace "$FILE")
|
||||||
|
sed -i "s/$REPLACE/\($REPLACEWITH\)/" "$1"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
fi
|
||||||
echo $link
|
echo $link
|
||||||
FILES=$(find . -iname "*$(basename $link)*")
|
FILES=$(find . -iname "*$(basename $link)*")
|
||||||
echo "$FILES" | cat --number
|
echo "$FILES" | cat --number
|
||||||
read PICK
|
read PICK
|
||||||
FILE=$(basename $(echo "$FILES" | head -n $PICK | tail -n 1) .md)
|
FILE=$(basename "$(echo "$FILES" | head -n $PICK | tail -n 1)" .md)
|
||||||
sed -i "s/$(escape '('$link')')/\($(escapeReplace $FILE)\)/" "$1"
|
REPLACE=$(escape '('$link')')
|
||||||
|
REPLACEWITH=$(escapeReplace "$FILE")
|
||||||
|
sed -i "s/$REPLACE/\($REPLACEWITH\)/" "$1"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
export -f searchfile
|
export -f searchfile
|
||||||
|
|
Loading…
Reference in New Issue