1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Unix script problem

  1. Mar 2, 2012 #1
    1. The problem statement, all variables and given/known data

    Trying to find how many numbers contains 5 between 1 to 4321

    2. Relevant equations

    n/a

    3. The attempt at a solution

    #!/bin/bash
    typeset -i current=1
    typeset -i times=0
    while [ $current -le 4321 ] ; do
    if [ ] ; then <<<<<<<<<<< stuck here, not sure what to put in if, tried grep etc nonthing works yet
    times=times+1
    fi
    current=current+1
    done
    echo there are $times numbers that has a 5
     
  2. jcsd
  3. Mar 2, 2012 #2
    nvm solved it just gonna add this for future people whos gonna look up this kind of problem in google

    if [[ $current = *[5] ]] ; then
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Unix script problem
  1. A shell script doubt (Replies: 5)

  2. Program vs Script (Replies: 10)

Loading...