Need help to make a loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help to make a loop
# 1  
Old 08-10-2011
Need help to make a loop

Below is my code. I want a loop in this way that if folder has tag sub-folder then it will show the list of tags otherwise it will show the subfolders of that folder and then again user will select sub-folder and if tags found then show the tag list otherwise show all subfolders till he finds the tag subfolder. Code should be append at the highlighted area

My code
Code:
unset Reponame

repolist()
{
  RepoList=/mnt/scm/subversion/
  cd ${RepoList}
  List=`ls|cut -d " " -f6`
  for i in ${List};do echo "${i}";done>/home/e030809/Repo.txt
    count=0
  cat /home/e030809/Repo.txt|while read line; do count=`echo $count + 1 | bc`; echo "$count)$line"; done|tee /home/e030809/Repo1.txt
}

sub_repolist()
{
  echo -en "Enter the number corresponding to the repository to check list of labels or type q to quit(1,2...):"
  read usrInput
  if [[ "${usrInput}" == "Q" || "${usrInput}" == "q" ]]; then
    return 0;
  else
    if [ -z $usrInput ];then
      return 0;
    fi
  fi
  cat /home/e030809/Repo1.txt|grep -w "$usrInput"|cut -d ")" -f2|head -1|tee /home/e030809/Repo2.txt
  Reponame=`cat /home/e030809/Repo2.txt|sed 's/[ \t]*$//' #`
  #echo $Reponame
}

sub_repolist1()
{
  svn ls http://vhldvsmsv001.tvlport.net/svn/${Reponame}/|cut -d "/" -f1 >/home/e030809/Repo3.txt (This command show the list of subfolders)
  find=`cat /home/e030809/Repo3.txt|grep -w "tags"|sed 's/[ \t]*$//' #`
  if [[ "$find" == "tags" ]];then
    svn ls http://vhldvsmsv001.tvlport.net/svn/${Reponame}/${find} (This command will show the list of tags because find variable has value tags)
  else
    echo -e "Repository "${Reponame}" has below modules.Please select appropriate number corresponding to module:"
    count=0
    cat /home/e030809/Repo3.txt|while read line; do count=`echo $count + 1 | bc`; echo "$count)$Reponame/$line"; done
  fi
}

repolist
sub_repolist
sub_repolist1

Last edited by Scott; 08-10-2011 at 08:12 AM.. Reason: You will not receive any further reminders about code tags...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to make a loop to read the input from a file part by part?

Hi All, We've a VDI infrastructure in AWS (AWS workspaces) and we're planning to automate the process of provisioning workspaces. Instead of going to GUI console, and launching workspaces by selecting individual users is little time consuming. Thus, I want to create them in bunches from AWS CLI... (6 Replies)
Discussion started by: arun_adm
6 Replies

2. Shell Programming and Scripting

How to make faster loop in multiple directories?

Hello, I am under Ubuntu 18.04 Bionic. I have one shell script run.sh (which is out of my topic) to run files under multiple directories and one file to control all processes running under those directories (control.sh). I set a cronjob task to check each of them with two minutes of intervals.... (3 Replies)
Discussion started by: baris35
3 Replies

3. Shell Programming and Scripting

Make awk gsub take value of for loop

I am running Debian, mksh shell and #!/bin/mksh script. Here is one instance I am trying to match. There are other level and n values, but they must be gathered in numerical order or the program will not work properly: level="0" n="0" Here is my code which does not work: { for (a = 0; a <=... (15 Replies)
Discussion started by: bedtime
15 Replies

4. Shell Programming and Scripting

How to make dynamic variable names for use in while loop?

i=0 while do sizesfor0=`cat 16 | grep 'pickSize' -A 1 | grep '_sz' | cut -d'_' -f1` sizesfor0=${sizesfor0//id=\"lll/:} IFS=: array0=( $sizesfor0 ) echo ${array0} i=$(( $i + 1 )) done So, right now I have two variables in the while statement above sizesfor0 and array0 The... (1 Reply)
Discussion started by: phpchick
1 Replies

5. Shell Programming and Scripting

make loop from input file

Hi Guys, I have file A.txt PP97 PP66 PP87 PP66 PP47 PP57 PP44 PP20 PP66 PP16 PP13 PP51 PP68 PP70 PP75 PP30 (2 Replies)
Discussion started by: asavaliya
2 Replies

6. Solaris

Gani Network Driver Won't Install - make: Fatal error: Don't know how to make targ...

I attached a README file that I will refer to. I successfully completed everything in the README file until step 4. # pwd /gani/gani-2.4.4 # ls COPYING Makefile.macros gem.c Makefile Makefile.sparc_gcc gem.h Makefile.amd64_gcc ... (1 Reply)
Discussion started by: Bradj47
1 Replies

7. Shell Programming and Scripting

[PHP] endless loop mimics a cron. Make sure only one instance is running

Hi, PHP user here. I'm using an endless loop to perform to mimic a cron. The script does something every 20 minutes. It sleep()s in the meantime. I have various checks that ensure that only instance can run, including a "gentleman agreement" locked file. However, I'd like to make sure... (2 Replies)
Discussion started by: jjshell
2 Replies

8. UNIX for Dummies Questions & Answers

a for loop that doesn't make sense

I've been referring bash info for processes and came across a structure for a process which is defined like typedef struct process { struct process *next; char ** argv . . . }process; What I don't understand is that in the program there's a for loop which goes like this job... (2 Replies)
Discussion started by: sdsd
2 Replies

9. UNIX for Dummies Questions & Answers

How to make a loop base on reading a file?

To make it clearer: I have a file, List.txt List.txt contains: (these are actually splitted files w/c I got from ls command and dump them to the List.txt file) SAMPLEa SAMPLEb SAMPLEc SAMPLEd SAMPLEe SAMPLEf . . . . . And I want to rename these files to have a .dat extension.... (3 Replies)
Discussion started by: JohnBalayo
3 Replies

10. HP-UX

How to make a loop base on reading a file?

Need help on making a loop script base on what is inside a file... File to read: List.txt List.txt contains below w/c are file name as well: SAMPLEa SAMPLEb SAMPLEc SAMPLEd SAMPLEe SAMPLEf . . . Want to make a loop that will manipulate those that are inside the file.txt w/c are... (3 Replies)
Discussion started by: JohnBalayo
3 Replies
Login or Register to Ask a Question