-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbs
More file actions
executable file
·40 lines (34 loc) · 1.32 KB
/
Copy pathbs
File metadata and controls
executable file
·40 lines (34 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Del.icio.us search script
DB=/home/enrique/bookmark-search/bookmarks.sqlite
PATTERN="$1"
if [ "${PATTERN}" != "" ]
then
sqlite3 "${DB}" '.mode lines' 'select title,url,tags,datetime(add_date, '\''unixepoch'\'') as date,comment from links where
tags like '\'"${PATTERN}"\'' or
tags like '\'"${PATTERN}"',%'\'' or
tags like '\''%,'"${PATTERN}"',%'\'' or
tags like '\''%,'"${PATTERN}"\''
order by date desc;' | less
else
read -p "url: " -e URL
ID=$(sqlite3 "${DB}" "select id from links where url='${URL}';")
if [ -n "${ID}" ]
then
TITLE=$(sqlite3 "${DB}" "select title from links where id=${ID}")
TAGS=$(sqlite3 "${DB}" "select tags from links where id=${ID}")
COMMENT=$(sqlite3 "${DB}" "select comment from links where id=${ID}")
fi
read -p "title: " -i "${TITLE}" -e TITLE
read -p "tags: " -i "${TAGS}" -e TAGS
read -p "comment: " -i "${COMMENT}" -e COMMENT
TITLE=$(echo "${TITLE}" | sed -e "s/'/''/g")
TAGS=$(echo "${TAGS}" | sed -e "s/'/''/g")
COMMENT=$(echo "${COMMENT}" | sed -e "s/'/''/g")
if [ -n "${ID}" ]
then
sqlite3 "${DB}" "update links set title='${TITLE}', tags='${TAGS}', comment='${COMMENT}', add_date='$(date +%s)' where id=${ID}"
else
sqlite3 "${DB}" "insert into links (url,title,tags,comment,add_date) values ('${URL}','${TITLE}','${TAGS}','${COMMENT}','$(date +%s)')"
fi
fi