How to this out in shell script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to this out in shell script?
# 1  
Old 04-03-2014
How to this out in shell script?

Hi All,

I running a command I am getting the output as below.
Quote:
symcfg -sid 624 list -fa all -address |egrep "FA-|Including Metamembers"|awk '{print $1,$3}'
Quote:
FA-5E 0
Including 3883
FA-6E 1
Including 3889
FA-11E 0
Including 27
FA-11E 1
Including 3883
FA-12E 0
Including 3889
FA-5F 0
Including 252
FA-6F 1
Including 252
FA-7F 0
Including 1440
FA-8F 1
Including 1440
FA-9F 1
Including 1440
FA-10F 0
Including 1448
FA-10F 1
Including 8
FA-11F 1
Including 252
FA-12F 0
Including 252

But I need the output in this format

Quote:
FA-5E 0,Including 3883
FA-6E 1,Including 3889
FA-11E 0,Including 27
FA-11E 1,Including 3883
FA-12E 0,Including 3889
FA-5F 0,Including 252
FA-6F 1,Including 252
FA-7F 0,Including 1440
FA-8F 1,Including 1440
FA-9F 1,Including 1440
FA-10F 0,Including 1448
FA-10F 1,Including 8
FA-11F 1,Including 252
FA-12F 0,Including 252

Last edited by ranjancom2000; 04-03-2014 at 08:14 AM..
# 2  
Old 04-03-2014
Hello,

Following may help. Please use code tags for commands as per forum rules.

Code:
awk '($0 ~ /FA/) {print $0;getline;print $0 "\n"}' ORS="," file_name | awk 'gsub(/^\,/,X) 1'

Output will be as follows.

Code:
FA-5E 0,Including 3883
FA-6E 1,Including 3889
FA-11E 0,Including 27
FA-11E 1,Including 3883
FA-12E 0,Including 3889
FA-5F 0,Including 252
FA-6F 1,Including 252
FA-7F 0,Including 1440
FA-8F 1,Including 1440
FA-9F 1,Including 1440
FA-10F 0,Including 1448
FA-10F 1,Including 8
FA-11F 1,Including 252
FA-12F 0,Including 252

Thanks,
R. Singh
# 3  
Old 04-03-2014
Hi Ranjancom2000,

Could you please provide output of below command ? This will help us to give you solution.
Code:
symcfg -sid 624 list -fa all -address

# 4  
Old 04-03-2014
Something like:
Code:
symcfg -sid 624 list -fa all -address|awk '/FA-|Including Metamembers/{ORS= NR%2 ? ",":"\n";print $1,$3}'

# 5  
Old 04-03-2014
So i need to you ack command from a file output

---------- Post updated at 09:42 AM ---------- Previous update was at 07:00 AM ----------

This is output for command

Quote:
$ symcfg -sid 000 list -fa all -address|more

Symmetrix ID: 000

Director Device Name Attr Address
---------------------- ----------------------------- ---- --------------
Ident Symbolic Port Sym Physical VBUS TID LUN
------ -------- ---- ---- ----------------------- ---- --- ---

FA-5E 05E 0 4A7A Not Visible (M) 0 00 000
132F Not Visible (M) 0 00 001
134D Not Visible (M) 0 00 002
136B Not Visible (M) 0 00 003
1389 Not Visible (M) 0 00 004
13A7 Not Visible (M) 0 00 005
13C5 Not Visible (M) 0 00 006
13E3 Not Visible (M) 0 00 007
1401 Not Visible (M) 0 00 008
141F Not Visible (M) 0 00 009
143D Not Visible (M) 0 00 00A
145B Not Visible (M) 0 00 00B
1479 Not Visible (M) 0 00 00C
1497 Not Visible (M) 0 00 00D
14B5 Not Visible (M) 0 00 00E
14D3 Not Visible (M) 0 00 00F
14F1 Not Visible (M) 0 00 010
150F Not Visible (M) 0 00 011
152D Not Visible (M) 0 00 012
154B Not Visible (M) 0 00 013
1569 Not Visible (M) 0 00 014
1587 Not Visible (M) 0 00 015
15A5 Not Visible (M) 0 00 016
15C3 Not Visible (M) 0 00 017
15E1 Not Visible (M) 0 00 018
15FF Not Visible (M) 0 00 019
161D Not Visible (M) 0 00 01A
163B Not Visible (M) 0 00 01B
1659 Not Visible (M) 0 00 01C
1677 Not Visible (M) 0 00 01D
1695 Not Visible (M) 0 00 01E
16B3 Not Visible (M) 0 00 01F
16D1 Not Visible (M) 0 00 020
16EF Not Visible (M) 0 00 021
170D Not Visible (M) 0 00 022
172B Not Visible (M) 0 00 023
1749 Not Visible (M) 0 00 024
1785 Not Visible (M) 0 00 025
17C1 Not Visible (M) 0 00 026
17FD Not Visible (M) 0 00 027
1839 Not Visible (M) 0 00 028
1875 Not Visible (M) 0 00 029
18B1 Not Visible (M) 0 00 02A
18ED Not Visible (M) 0 00 02B
1929 Not Visible (M) 0 00 02C
1965 Not Visible (M) 0 00 02D
19A1 Not Visible 0 00 02E
19A2 Not Visible 0 00 02F
19A3 Not Visible 0 00 030
19A4 Not Visible 0 00 031
19A5 Not Visible 0 00 032
19A6 Not Visible 0 00 033
19A7 Not Visible 0 00 034
19A8 Not Visible 0 00 035
3B7D Not Visible (M) 0 00 036
3B80 Not Visible 0 00 037
3B81 Not Visible 0 00 038
3C36 Not Visible (M) 0 00 039
3C54 Not Visible (M) 0 00 03A
3B82 Not Visible (M) 0 00 03B
3BA0 Not Visible (M) 0 00 03C
3BBE Not Visible (M) 0 00 03D
3BFA Not Visible (M) 0 00 03E
3C18 Not Visible (M) 0 00 03F
3BDC Not Visible (M) 0 00 040
3C72 Not Visible (M) 0 00 041
3C90 Not Visible (M) 0 00 042
3CAE Not Visible (M) 0 00 043
3CCC Not Visible (M) 0 00 044
3CEA Not Visible (M) 0 00 045
3D08 Not Visible (M) 0 00 046
3D26 Not Visible (M) 0 00 047
3D62 Not Visible (M) 0 00 048
3D9E Not Visible (M) 0 00 049
3DDA Not Visible (M) 0 00 04A
3E16 Not Visible (M) 0 00 04B
3E52 Not Visible (M) 0 00 04C
3E8E Not Visible (M) 0 00 04D
3ECA Not Visible (M) 0 00 04E
3F06 Not Visible (M) 0 00 04F
3F42 Not Visible (M) 0 00 050
3F7E Not Visible (M) 0 00 051
3F84 Not Visible (M) 0 00 052
3F8A Not Visible (M) 0 00 053
3F90 Not Visible (M) 0 00 054
3F96 Not Visible (M) 0 00 055
3FB2 Not Visible (M) 0 00 056
400C Not Visible (M) 0 00 057
402A Not Visible (M) 0 00 058
4048 Not Visible (M) 0 00 059
4066 Not Visible (M) 0 00 05A
4084 Not Visible (M) 0 00 05B
40A2 Not Visible (M) 0 00 05C
40C0 Not Visible (M) 0 00 05D
40DE Not Visible (M) 0 00 05E
40FC Not Visible (M) 0 00 05F
411A Not Visible (M) 0 00 060
4138 Not Visible (M) 0 00 061
4156 Not Visible (M) 0 00 062
4174 Not Visible (M) 0 00 063
4192 Not Visible (M) 0 00 064
41B0 Not Visible (M) 0 00 065
41CE Not Visible (M) 0 00 066
41EC Not Visible (M) 0 00 067
420A Not Visible (M) 0 00 068
4228 Not Visible (M) 0 00 069
4246 Not Visible (M) 0 00 06A
4A98 Not Visible (M) 0 00 06B
4AB6 Not Visible (M) 0 00 06C
4AD4 Not Visible (M) 0 00 06D
4AF2 Not Visible (M) 0 00 06E
4B10 Not Visible (M) 0 00 06F
4B2E Not Visible (M) 0 00 070
4B4C Not Visible (M) 0 00 071
4B6A Not Visible (M) 0 00 072
4B88 Not Visible (M) 0 00 073
4BA6 Not Visible (M) 0 00 074
4BC4 Not Visible (M) 0 00 075
4BE2 Not Visible (M) 0 00 076
4C00 Not Visible (M) 0 00 077
4C1E Not Visible (M) 0 00 078
4C3C Not Visible (M) 0 00 079
4C5A Not Visible (M) 0 00 07A
4C78 Not Visible (M) 0 00 07B
Total ----
Mapped Devices: 124
Including Metamembers: 3883
Available Addresses: 213 (s)
---------- Post updated at 09:42 AM ---------- Previous update was at 09:42 AM ----------
# 6  
Old 04-04-2014
Use:
Code:
symcfg -sid 000 list -fa all -address|awk '/^FA-|Including Metamembers/{ORS= $0 ~ "^FA" ? ",":"\n";print $1,$3}'

# 7  
Old 04-04-2014
Quote:
symcfg -sid 000 list -fa all -address|awk '/^FA-|Including Metamembers/{ORS= $0 ~ "^FA" ? ",":"\n";print $1,$3}'
This one give output only the

Quote:
Including 1
Including 1
Including 587
Including 2494
Including 1
Including 1
Including 2467
Including 1

But no problem i got the solution which works

Quote:
symcfg -sid $f list -fa all -address |egrep "FA-|Including Metamembers"|awk '{print $1,$3}' > dd
awk '($0 ~ /FA/) {print $0;getline;print $0 "\n"}' ORS="," dd | awk 'gsub(/^\,/,X) 1'|sort -n -k 1.19,1.24
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script newbie- how to generate service log from shell script

Hi, I am totally a newbie to any programming languages and I just started an entry level job in an IT company. One of my recent tasks is to create a script that is able to show the log file of linux service (i.e. ntpd service) lets say, if I run my script ./test.sh, the output should be... (3 Replies)
Discussion started by: xiaogeji
3 Replies

2. Shell Programming and Scripting

Pass C shell array to another C shell script(csh) and shell(sh)

Dear Friends, Please help me on this my script name is send.csh In this i have written the statement like this set args = ( city state country price ) I want to pass this array to another c shell called receiver.csh. and i want to use it in this c shell or how to pass to... (2 Replies)
Discussion started by: SA_Palani
2 Replies

3. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

5. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

6. Shell Programming and Scripting

Correct shell script to Call One shell script from another shell script

Hi All, I have new for shell scripting. Problem : I have one scrip at serv1 and path of server is /apps/dev/provimage/scripts and script name:extract_ancillary.bat. I need to call this script at server2(my working server) and execute at server2 . Please let me know how to build the... (5 Replies)
Discussion started by: Vineeta Nigam
5 Replies

7. Shell Programming and Scripting

call another shell script and pass parameters to that shell script

Hi, I basically have 2 shell scripts. One is a shell script will get the variable value from the user. The variable is nothing but the IP of the remote system. Another shell script is a script that does the job of connecting to the remote system using ssh. This uses a expect utility in turn. ... (2 Replies)
Discussion started by: sunrexstar
2 Replies

8. Shell Programming and Scripting

How to use ssh execute other shell script on other host (shell script include nohup)?

i want use ssh on the host01 to execute autoexec.sh on the host02 like following : host01> ssh host02 autoexec.sh autoexec.sh include nohup command like follwing : nohup /home/jack/deletedata.sh & after i execute ssh host02 autoexec.sh one the host01. i can't found deletedata.sh... (1 Reply)
Discussion started by: orablue
1 Replies

9. Shell Programming and Scripting

invoking a shell script inside cgi shell script

Hi, I have an HTML form through which I get some text as input. i need to run a shell script say script.sh inside a perl-cgi script named main_cgi.sh on the form input. I want to write the contents of the form in a file and then perform some command line operations like grep, cat on the text... (2 Replies)
Discussion started by: smriti_shridhar
2 Replies

10. Shell Programming and Scripting

How to Run a shell script from Perl script in Parent shell?

Hi Perl/UNIX experts, I have a problem in running a shell script from my perl script (auto.pl). I run the perl script using perl auto.pl from the shell prompt The shell script picks the files in "input" folder and procesess it. The shell script blue.sh has this code. export... (16 Replies)
Discussion started by: hifake
16 Replies
Login or Register to Ask a Question