tSimple way to delete a line - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit a322bc717e3166be6c0a9ac4fa6037bdd8a0fc9b
(DIR) parent 838a79c6561ff117e4a04df0fa08a1a689a034ca
(HTM) Author: z3bra <willy@mailoo.org>
Date: Thu, 23 Oct 2014 15:37:36 +0200
Simple way to delete a line
Diffstat:
M todo | 8 ++++++++
1 file changed, 8 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/todo b/todo
t@@ -26,6 +26,14 @@ append() {
echo "$*" >> $TODO
}
+delete() {
+ test -n "$1" || exit 1
+ sed -i "${1}d" $TODO
+}
+
+# delete line "$2" (see delete() function)
+test "$1" = '-d' && delete "$2" && exit 0
+
# append arguments to the file, or print it otherwise
test -n "$*" && append $* || list