Need your help to get the output of the list in desired format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need your help to get the output of the list in desired format
# 8  
Old 07-26-2011
use
Code:
grep -w

# 9  
Old 07-27-2011
Now I am getting the desired result for my script
I used one more thing head -1

repolist() { cd ${CHDIR} Repo=`ls|cut -d " " -f1` echo "Enter the REPO # : " read usrInput count=0 echo "$Repo" | while read line; do count=`echo $count + 1 | bc`; echo " $count : $line "; done | grep $usrInput|head -1 }

output
1)BSB 2)CIB 3)COB 4)DCI 5)DIB 6)DSB 7)ESB-P 8)ESB-TOOLS 9)FareVerify 10)GCACHE 11)GWY 12)IBMSOAMB 13)IBMSOAWAS 14)ISM 15)KESTREL-DEV 16)kestrel-migration 17)KESTREL-UAPI 18)KESTREL-XD 19)LAMB 20)LinuxAutomation 21)MGLNO 22)PORTAL 23)repos4 24)SCMTools 25)SESTOKEN 26)SMB 27)SOA 28)SPLASH 29)SSB 30)STP 31)TOI

Enter the REPO number(1,2...):23
23)repos4

Can u help me to cut the above output
right now it's showing me
23)repos4 but I want this in repos4 only


Thanks in advance

---------- Post updated at 06:52 PM ---------- Previous update was at 06:20 PM ----------

Now I have also got the desired output through cut commnand

Thank you very much for your kind help
Rohit

---------- Post updated at 11:24 PM ---------- Previous update was at 06:52 PM ----------

Hello Guys,

The output of my file is below and I want to delete those lines from the file where these kind of numbers (e.g. 11.2.13.1)are coming.Highlighted in red

BSB/
BSB/ADS
CIB/
CIB/CRH
CIB/DCC
CIB/EMD
CIB/GDSPresentation
CIB/HCH
CIB/HSM
CIB/MCH
CIB/RCH
COB/
DCI/
DIB/
DIB/H2H
DIB/HotelSync
DIB/UADBA
DSB/
DSB/HotelETL
ESB-P/
ESB-TOOLS/
FareVerify/
GCACHE/
GWY/
IBMSOAMB/
IBMSOAWAS/
ISM/
KESTREL-DEV/
KESTREL-UAPI/
KESTREL-UAPI/branches/11.0
KESTREL-UAPI/branches/11.1
KESTREL-UAPI/branches/11.1.09.2
KESTREL-UAPI/branches/11.2
KESTREL-UAPI/branches/11.2.13.1
KESTREL-UAPI/branches/11.3

KESTREL-XD/
LAMB/
LinuxAutomation/
MGLNO/
PORTAL/
PORTAL/AdminPortal
PORTAL/Common
PORTAL/TUD
PORTAL/UDP
PORTAL/UDP/udportal/branches/11.00.04
PORTAL/UDP/udportal/trunk
repos4/
SCMTools/
SESTOKEN/
SMB/
SOA/
SPLASH/branches
SPLASH/tags
SSB/SystemServices
STP/
TOI/

Thanks in advance
# 10  
Old 07-27-2011
Code:
 
grep -v "[0-9]" fileName

# 11  
Old 07-28-2011
Below is the code but I need one more thing here.This code works fine and list the repo with numbers.I need here is

I want to restrict the person to enter 0(zero) as well as to enter exceed than count .i.e. if count=56 and if he enters 57 it should not work and same for 0 because here
what happens when I enter 0 it say no repo. exist but it pick the value of those repo. which contains 0 (for. eg. KESTREL-UAPI/branches/11.0).and same for max. count(for e.g. if KESTREL-UAPI/branches/11.57) then it should also not work.

repocodebase()
{
echo -en "Enter the REPO number(1,2...):"
read usrInput
count=0
cat /home/e030809/temp.txt2|while read line; do count=`echo $count + 1 | bc`; echo " $count)$line "; done | grep -w $usrInput>/home/e030809/temp.txt3
}

List of repo:-

1)BSB
2)BSB/ADS
3)CIB
4)CIB/CRH
5)CIB/DCC
6)CIB/EMD
7)CIB/GDSPresentation
8)CIB/HCH
9)CIB/HSM
10)CIB/MCH
11)CIB/RCH
12)COB
13)DCI
14)DIB
15)DIB/H2H
16)DIB/HotelSync
17)DIB/UADBA
18)DSB
19)DSB/HotelETL
20)ESB-P
21)ESB-TOOLS
22)FareVerify
23)GCACHE
24)GWY
25)IBMSOAMB
26)IBMSOAWAS
27)ISM
28)KESTREL-DEV
29)KESTREL-UAPI
30)KESTREL-UAPI/branches/11.0
31)KESTREL-UAPI/branches/11.1
32)KESTREL-UAPI/branches/11.1.09.2
33)KESTREL-UAPI/branches/11.2
34)KESTREL-UAPI/branches/11.2.13.1
35)KESTREL-UAPI/branches/11.3

36)KESTREL-XD
37)LAMB
38)LinuxAutomation
39)MGLNO
40)PORTAL
41)PORTAL/AdminPortal
42)PORTAL/Common
43)PORTAL/TUD
44)PORTAL/UDP
45)PORTAL/UDP/udportal/branches/11.00.04
46)PORTAL/UDP/udportal/trunk
47)repos4
48)SCMTools
49)SESTOKEN
50)SMB
51)SOA
52)SPLASH/branches
53)SPLASH/tags
54)SSB/SystemServices
55)STP
56)TOI

Thanks-
Rohit Singh
# 12  
Old 07-28-2011
Code:
 
repocodebase()
{
echo -en "Enter the REPO number(1,2...):"
read usrInput
count=0
fileName="/home/e030809/temp.txt2"
while read line; do count=`echo $count + 1 | bc`; echo " $count)$line "; done < $fileName
[ "$usrInput" -le "$count" -o "$usrInput" -ne "0" ] && grep -w $usrInput > /home/e030809/temp.txt3 || echo "No Repo Exists"
}

# 13  
Old 07-28-2011
Example to use select. Ksh93 and bash support it. Like for except give the selection prompt.
Code:
cd $CHDIR
PS3="Your choice (ENTER=menu again, e=end):"
select f in *
do
        [ "$REPLY" = "e" ] && break
        echo "Choice: ($REPLY) $f"
        [ ! -f "$f" ] && echo "not regular file" >&2 && continue
        echo $f
        # if like to exit after 1st selection, then add line break
        # break
done

# 14  
Old 07-28-2011
I tried your code but I don't why it's not working when I enter 0 it doesn't give me
"No Repo Exists" either I enter more than the count.I aslo checked the temp.txt3 this file is also empty on entering the valid number.When I enter the repo number after that it is also displaying the whole list that is not required.I also echo the value of userinput and count and its giving me the correct response.Please do the needful
#!/bin/bash

repocodebase()
{
echo -en "Enter the REPO number(1,2...):"
read usrInput
count=0
fileName="/home/e030809/temp.txt2"
while read line; do count=`echo $count + 1 | bc`; echo " $count)$line "; done < "$fileName"
echo $usrInput
echo $count
[ "$usrInput" -le "$count" -o "$usrInput" -ne "0" ] && grep -w $usrInput > /home/e030809/temp.txt3 || echo "No Repo Exists"
}
repocodebase

output

[e030809@vhldvsmsv001 ~]$ ./test
Enter the REPO number(1,2...):0
1)BSB
2)BSB/ADS
3)CIB
4)CIB/CRH
5)CIB/DCC
6)CIB/EMD
7)CIB/GDSPresentation
8)CIB/HCH
9)CIB/HSM
10)CIB/MCH
11)CIB/RCH
12)COB
13)DCI
14)DIB
15)DIB/H2H
16)DIB/HotelSync
17)DIB/UADBA
18)DSB
19)DSB/HotelETL
20)ESB-P
21)ESB-TOOLS
22)FareVerify
23)GCACHE
24)GWY
25)IBMSOAMB
26)IBMSOAWAS
27)ISM
28)KESTREL-DEV
29)KESTREL-UAPI
30)KESTREL-UAPI/branches/11.0
31)KESTREL-UAPI/branches/11.1
32)KESTREL-UAPI/branches/11.1.09.2
33)KESTREL-UAPI/branches/11.2
34)KESTREL-UAPI/branches/11.2.13.1
35)KESTREL-UAPI/branches/11.3
36)KESTREL-XD
37)LAMB
38)LinuxAutomation
39)MGLNO
40)PORTAL
41)PORTAL/AdminPortal
42)PORTAL/Common
43)PORTAL/TUD
44)PORTAL/UDP
45)PORTAL/UDP/udportal/branches/11.00.04
46)PORTAL/UDP/udportal/trunk
47)repos4
48)SCMTools
49)SESTOKEN
50)SMB
51)SOA
52)SPLASH/branches
53)SPLASH/tags
54)SSB/SystemServices
55)STP
56)TOI
0
56

Thanks-
Rohit Singh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Desired Date format

I need to get the current year for the files that has been created today. Ex- when i list in unix console it shows ls -l abc.txt -rw-rw-r-- 1 user1 user1 33 May 2 08:58 abc.txt but i need to get as May 2 2013 , i dont need 08:58 is there any command to list it out in that... (7 Replies)
Discussion started by: Prashanth B
7 Replies

2. UNIX for Dummies Questions & Answers

How to print the line from the file in the desired format:?

I am reading a file of Linux ( like mentioned below) & the data is represented in a single line like mentioned below: 11/03 4:00 39992 0.098 5.195 0.034 0.001 1.091 182 0.000 0 0.071 4.252 0.033 0.001 666.53 Now i want to print the result in other file something like this :- 39992... (5 Replies)
Discussion started by: Anamica
5 Replies

3. Shell Programming and Scripting

How to grep the desired output and output to a file?

currently I have process from a raw file to this stage ALTER TABLE "EXCEL_ADMIN"."TC_TXN_VOID" ADD CONSTRAINT "PK_TC_TXN_VOID" PRIMARY KEY ("TC_TXN_IID") ALTER TABLE "EXCEL_ADMIN"."TC_TXN_AMT" ADD CONSTRAINT "PK_TC_TXN_AMT" PRIMARY KEY ("TC_TXN_AMT_IID") ALTER TABLE... (10 Replies)
Discussion started by: jediwannabe
10 Replies

4. UNIX for Dummies Questions & Answers

Help with saving file in desired format

Hi I have the following file in the unix named emp. ID,NAME,SAL,DEPT 101,aaa,2000,10 102,bbb,3000,20 103,ccc,4000,30 104,ddd,5000,40 105,aaa,2000,50 106,bbb,3000,60 107,ccc,4000,70 108,ddd,5000,10 109,aaa,2000,80 I need to save first 3 columns(ID, NAME, SAL) in another file with... (2 Replies)
Discussion started by: alok3141
2 Replies

5. Shell Programming and Scripting

need to get the desired output

Below is the my cide which is working fine but I am not getting the output indesired format.there is some problem in alignment.Can someone help me to correct this? if ]; then summary=$( echo -e "Please review the log file of auto coloclean utility.\n"; echo -e... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies

6. Shell Programming and Scripting

SED - output not desired

echo '0x3f 0xfa ae 0xeA' | sed '/0x/ y/abcdef/ABCDEF/' output: 0x3F 0xFA AE 0xEA echo '0x3f 0xfa ae 0xeA' | sed -r '/0x{2}/ y/abcdefg/ABCDEFG/' output: 0x3F 0xFA AE 0xEA my expected output: 0x3F 0xFA ae 0xEA What I want to achieve is change all hexadecimals to UPPER case(only those... (6 Replies)
Discussion started by: kevintse
6 Replies

7. HP-UX

Desired Format !

Hi everybody, I just need desired ouput from text file which should have folowing format; "2007-06-25 00:03:32.926+05:30",12354369,"Load","Completed","Rs.-5,556.00",9452217714 "2007-06-25 00:06:57.357+05:30",12354371,"Load","Completed","Rs.-56.00",9415766266 "2007-06-25... (1 Reply)
Discussion started by: prasanth_babu
1 Replies

8. Shell Programming and Scripting

Help me in getting the desired output

I wanted to put "|" this sign at starting and at end of every field but its not working with first field like Currently the out put is : abc | abc | abc | xyz | xyz | xyz | But I want the out put in this form: | abc | abc | abc | | xyz | xyz | xyz | plz help me. (2 Replies)
Discussion started by: akash
2 Replies

9. UNIX for Advanced & Expert Users

get the timestamp of a file in desired format

Hi, I have a file say abc. I get the timestamp in following way: ls -ltr abc | awk -F" " '{print $6,$7,$8}' Mar 8 10:23 I need to get the timestamp as : 03-08-2007 10:23:00 Thanks Sumeet (1 Reply)
Discussion started by: sumeet
1 Replies

10. UNIX for Dummies Questions & Answers

capturing the time stamp in desired format

Hello All, I am working on korn shell script.i have 2 questions; 1) I have a file and i am able to capture the arrival time. the arrival time is capturing as 11:30 ls -ltr aaa.bbb.332121312.*.* | awk -F" " '{print $8}' 11:30 my desired output is 113000 can anyone please suggest me... (2 Replies)
Discussion started by: pavan_test
2 Replies
Login or Register to Ask a Question