The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using sed to print a ruler doubleminus UNIX for Dummies Questions & Answers 5 05-04-2008 01:15 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 10-19-2005
whatisthis's Avatar
Registered User
 

Join Date: Aug 2004
Posts: 175
ruler

Hi,
I remembered that I used the ruler command at the unix prompt.
But I tried to use it again and it says that command not found.
I don't know what had happened.

It's in the command not in VI, right?

Thanks!
Reply With Quote
Forum Sponsor
  #2  
Old 10-19-2005
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
I use my own ruler script....

Code:
# ./ruler.sh 50
    5    10   15   20   25   30   35   40   45   50
....|....|....|....|....|....|....|....|....|....|
Is that the sort of thing you want?

Code:
#! /bin/ksh

if [ "$#" -ne "1" ]; then
  echo "usage: `basename $0` width"
  exit 1
fi

if [ "$1" -lt "1" -o "$1" -gt "100" ]; then
  echo "ruler: invalid width entered"
  echo "please enter width between 1 and 100"
  exit 1
fi

# First step
# ==========
# Print char numbers
#
size=$1
i=0
count_cntl=0

while [ "$i" -le "$size" ]
do
  let "count_cntl = $count_cntl + 1"
  if [ "$count_cntl" -eq 5 ]; then
    count_cntl=1
  fi

  if [ "$i" -eq "0" ]; then
    let "i = $i + 1"
    continue
  fi

  mod=$(( $i % 5 ))
  if [ "$mod" -eq "0" ]; then
    echo "${i}\c"
  else
    if [ "$i" -lt "10" ]; then
      echo " \c"
    else
      if [ "$count_cntl" -eq 3 ]; then
         let "count_cntl = $count_cntl + 1"
      else
         echo " \c"
      fi
    fi
  fi
  let "i = $i + 1"
done

echo ""


# Second step
# ===========
# Print ruler itself

size=$1
i=0

while [ "$i" -le "$size" ]
do
  if [ "$i" -eq "0" ]; then
     let "i = $i + 1"
     continue
  fi

  mod=$(( $i % 5 ))
  if [ "$mod" -eq "0" ]; then
    echo "|\c"
  else
    echo ".\c"
  fi

  let "i = $i + 1"
done

echo "\n"

exit 0
Cheers
ZB
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0