# HG changeset patch # User HackBot # Date 1464138825 0 # Node ID 02c762f3dc024b1edd9345590a94092167e9453e # Parent 4b446e13635d30a1d0623b4794d73bde145aa80a ` mv DMCj bin/med diff -r 4b446e13635d -r 02c762f3dc02 DMCj --- a/DMCj Wed May 25 01:13:30 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -#! /bin/bash -numcheck='^[0-9]\+$' -add_after_line () { { sed "$1q"; echo "$2"; sed "1,$1d"; } < "$3" > /tmp/medtmp; mv /tmp/medtmp "$3"; } #Thanks izabera! -if [ "$1" == "rl" ]; then - if [[ "$2" =~ $numcheck ]]; then - echo "error: Not a number" >&2;exit 1 - fi - NUM="$2" - cat "$3" | sed "${NUM}q;d" #Read line command - exit 0 -fi -if [ "$1" == "ap" ]; then - filename="$3" - echo "$2" >> "$filename" #Append command - exit 0 -fi -if [ "$1" == "hp" ]; then - echo "View the inside of the file for more info, rl, anyone?" - exit 0 -fi -if [ "$1" == "il" ]; then #insert at - if [[ "$2" =~ $numcheck ]]; then - echo "error: Not a number" >&2;exit 1 - fi - - add_after_line "$2" "$3" "$4" - exit 0 -fi - diff -r 4b446e13635d -r 02c762f3dc02 bin/med --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/med Wed May 25 01:13:45 2016 +0000 @@ -0,0 +1,29 @@ +#! /bin/bash +numcheck='^[0-9]\+$' +add_after_line () { { sed "$1q"; echo "$2"; sed "1,$1d"; } < "$3" > /tmp/medtmp; mv /tmp/medtmp "$3"; } #Thanks izabera! +if [ "$1" == "rl" ]; then + if [[ "$2" =~ $numcheck ]]; then + echo "error: Not a number" >&2;exit 1 + fi + NUM="$2" + cat "$3" | sed "${NUM}q;d" #Read line command + exit 0 +fi +if [ "$1" == "ap" ]; then + filename="$3" + echo "$2" >> "$filename" #Append command + exit 0 +fi +if [ "$1" == "hp" ]; then + echo "View the inside of the file for more info, rl, anyone?" + exit 0 +fi +if [ "$1" == "il" ]; then #insert at + if [[ "$2" =~ $numcheck ]]; then + echo "error: Not a number" >&2;exit 1 + fi + + add_after_line "$2" "$3" "$4" + exit 0 +fi +