Permalink
Browse files

shell scripts on argument parsing, counting log lines, greeing and

talking
  • Loading branch information...
1 parent 96cccba commit a648cceb80a7991aa65cfe7c98288599992d334f Manju Rajashekhar committed Jan 7, 2012
Showing with 52 additions and 0 deletions.
  1. +7 −0 sh/argv.sh
  2. +15 −0 sh/countlines.sh
  3. +5 −0 sh/greet.sh
  4. +25 −0 sh/talk.sh
View
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+echo "`basename $0` has $# arguments:"
+while [ $# -gt "0" ]; do
+ echo "$1"
+ shift
+done
View
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+file=
+lines=
+sleep=
+i=0
+
+while [ 1 ]; do
+ tail -n $lines $file > /tmp/a.txt
+ sleep $sleep
+ tail -n $lines $file > /tmp/b.txt
+ ans=`diff -u /tmp/a.txt /tmp/b.txt | grep "^+" | grep -n -v "+++" | grep -n " 500\| 502\| 503"`
+ i=`expr $i + 1`
+ echo "$i : $ans"
+done
View
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+echo "What is your name?"
+read MY_NAME
+!echo "Hello $MY_NAME - hope you're well"
View
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+echo "Please talk to me ..."
+
+while [ 1 ]; do
+ read input_string
+ case $input_string in
+ hello)
+ echo "Hello yourself!"
+ ;;
+
+
+ bye)
+ echo "See you again!"
+ break
+ ;;
+
+ *)
+ echo "Sorry, I don't understand"
+ ;;
+ esac
+done
+
+echo
+echo "That's all folks"

0 comments on commit a648cce

Please sign in to comment.