Solving Unix Script Problem: Finding #s w/ 5 1-4321

  • Thread starter Thread starter Bimpo
  • Start date Start date
  • Tags Tags
    Unix
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
Bimpo
Messages
9
Reaction score
0

Homework Statement



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

Homework Equations



n/a

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
 
Physics news on Phys.org
nvm solved it just going to add this for future people whos going to look up this kind of problem in google

if [[ $current = *[5] ]] ; then