handling CSV file to get desired output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting handling CSV file to get desired output
# 1  
Old 01-12-2012
handling CSV file to get desired output

Hi All , i have a CSV file , pattern is given below :-
Code:
Group # name # host # account # stop # # start # # check 
--------------------------------------------------------------------------

file format and data exmaple :-
Code:
RBP2,RB0112,sihrb001,tksrb011,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn RB0112,,. ./.profile 1>/dev/null 2>&1;nohup rtprio 100 ART_AMC_Start_AVM_ksh -n RB0112 -e gnavm_ewd & 1>/dev/null,,ps -fu \$LOGNAME | grep 'olcServer -n RB0112'|grep -vgrep                                                                                                     
RBP2,RB0212,sihrb001,tksrb011,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn RB0212,,. ./.profile 1>/dev/null 2>&1;nohup rtprio 100 ART_AMC_Start_AVM_ksh -n RB0212 -e gnavm_ewd & 1>/dev/null,,ps -fu \$LOGNAME | grep 'olcServer -n RB0212'|grep -vgrep                                                                                                     
RBS2,RB0622,sihrb001,tksrb011,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn RB0622,,. ./.profile 1>/dev/null 2>&1;nohup rtprio 100 ART_AMC_Start_AVM_ksh -n RB0622 -e gnavm_ewd & 1>/dev/null,,ps -fu \$LOGNAME | grep 'olcServer -n RB0622'|grep -vgrep                                                                                                     
RBP1,RB0111,sihrb001,tksrb011,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn RB0111,,. ./.profile 1>/dev/null 2>&1;nohup rtprio 100 ART_AMC_Start_AVM_ksh -n RB0111 -e gnavm_ewd & 1>/dev/null,,ps -fu \$LOGNAME | grep 'olcServer -n RB0111'|grep -vgrep                                                                                                     
RBP1,RB0211,sihrb001,tksrb011,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn RB0211,,. ./.profile 1>/dev/null 2>&1;nohup rtprio 100 ART_AMC_Start_AVM_ksh -n RB0211 -e gnavm_ewd & 1>/dev/null,,ps -fu \$LOGNAME | grep 'olcServer -n RB0211'|grep -vgrep                                                                                                     
RBS1,RB0621,sihrb001,tksrb011,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn RB0621,,. ./.profile 1>/dev/null 2>&1;nohup rtprio 100 ART_AMC_Start_AVM_ksh -n RB0621 -e gnavm_ewd & 1>/dev/null,,ps -fu \$LOGNAME | grep 'olcServer -n RB0621'|grep -vgrep                                                                                                     
XLA,XLAOLC011,sihrb001,tksrb011,. ./.profile 1>/dev/null 2>&1;ps -fe|grep XLA_OLC011|grep -w 'xladaemon'|grep -v grep |tr -s '[ ]' '[ ]'|cut -d ' ' -f 2|xargs kill -9,,. ./.profile 1>/dev/null 2>&1;nohup ART_AMC_Start_ksh -i XLA_OLC011 -b xladaemon -m "pm olc" -t olc -n RATER -x N &,,ps -fu \$LOGNAME | grep 'xladaemon -n XLA_OLC011'|grep -vgrep
XLA,XLAOLC032,sihrb001,tksrb011,. ./.profile 1>/dev/null 2>&1;ps -fe|grep XLA_OLC032|grep -w 'xladaemon'|grep -v grep |tr -s '[ ]' '[ ]'|cut -d ' ' -f 2|xargs kill -9,,. ./.profile 1>/dev/null 2>&1;nohup ART_AMC_Start_ksh -i XLA_OLC032 -b xladaemon -m "pm olc" -t olc -n RATER -x N &,,ps -fu \$LOGNAME | grep 'xladaemon -n XLA_OLC032'|grep -vgrep
RBFOFFP,RBF011,sihrb001,tksrb011,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn RBF011,,. ./.profile 1>/dev/null 2>&1;nohup rtprio 100 ART_AMC_Start_ksh -i RBF011 -b olcServer -m "pm olc" -t olc -n RATER -x Y &,,ps -fu \$LOGNAME | grep 'olcServer -n RBF011'|grep -vgrep                                                                                 
RBFOFFS,RBF032,sihrb001,tksrb011,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn RBF032,,. ./.profile 1>/dev/null 2>&1;nohup rtprio 100 ART_AMC_Start_ksh -i RBF032 -b olcServer -m "pm olc" -t olc -n RATER -x Y &,,ps -fu \$LOGNAME | grep 'olcServer -n RBF032'|grep -vgrep                                                                                 
AGENTR,AGENTR01,sihrb001,tksrb011,. ./.profile 1>/dev/null 2>&1;ps -fe|grep   AGENTR01 |grep -w gn1avm_agent|tr -s '[ ]' '[ ]'|cut -d ' ' -f 2|xargs kill -9,,. ./.profile 1>/dev/null 2>&1;nohup gn1avm_runproc_Ksh -e OLC1AVMA  -n AGENTR01 &,,ps -fu \$LOGNAME | grep 'gn1avm_agent -n AGENTR01$'|grep -vgrep                                          
SYNC,SYNC011,sihrb001,tksrb011,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn SYNC011,,. ./.profile 1>/dev/null 2>&1;nohup ART_AMC_Start_ksh -i SYNC011 -b olcServer -m "pm olc" -t olc -n RATER -x N &,,ps -fu \$LOGNAME | grep 'olcServer -n SYNC011'|grep -vgrep                                                                                           
SYNC,SYNC032,sihrb001,tksrb011,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn SYNC032,,. ./.profile 1>/dev/null 2>&1;nohup ART_AMC_Start_ksh -i SYNC032 -b olcServer -m "pm olc" -t olc -n RATER -x N &,,ps -fu \$LOGNAME | grep 'olcServer -n SYNC032'|grep -vgrep

Requirement :-

i have a script which is using this CSV file. that script will use group name (first coloumn) and collect all daemons in same group and will perform action , start/stop/check. example is below - so select group and go ahead with action on next menu page
13) RBFOFFP
14) RBFOFFS
15) RPL
16) CM
17) SED
18) SYNC

i want - to arrange these groups based on below requirements :-
1. i can bounce all the daemons on each server .(This seems easy , can do ,search all server names and redirect to new file and change group name)
2. IMPORTANT - suppose i want to handle few daemons , like we have one unique ID , i want to search that id and handle those daemons only .
example - on server 1 , 5-6 type of daemons are running , RB0111, RB0211, RB0112, RB0212 , RBF011, XLA011, SYNC011, .....unique ids here are - 01,02.....44 , and for daemon- RB , format is like , [unique_id][1-2][1-2] but for other daemons format is [unique_id][1-2]
if i say i want to handle all d daemons of unique_id = 15 , it means i shoudl get below daemons :-


Code:
RBP2,RB1512,sihrb008,tksrb151,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn RB1512,,. ./.profile 1>/dev/null 2>&1;nohup rtprio 100 ART_AMC_Start_AVM_ksh -n RB1512 -e gnavm_ewd & 1>/dev/null,,ps -fu \$LOGNAME | grep 'olcServer -n RB1512'|grep -vgrep                                                                                                     
RBP1,RB1511,sihrb008,tksrb151,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn RB1511,,. ./.profile 1>/dev/null 2>&1;nohup rtprio 100 ART_AMC_Start_AVM_ksh -n RB1511 -e gnavm_ewd & 1>/dev/null,,ps -fu \$LOGNAME | grep 'olcServer -n RB1511'|grep -vgrep                                                                                                     
XLA,XLAOLC151,sihrb008,tksrb151,. ./.profile 1>/dev/null 2>&1;ps -fe|grep XLA_OLC151|grep -w 'xladaemon'|grep -v grep |tr -s '[ ]' '[ ]'|cut -d ' ' -f 2|xargs kill -9,,. ./.profile 1>/dev/null 2>&1;nohup ART_AMC_Start_ksh -i XLA_OLC151 -b xladaemon -m "pm olc" -t olc -n RATER -x N &,,ps -fu \$LOGNAME | grep 'xladaemon -n XLA_OLC151'|grep -vgrep
RBFOFFP,RBF151,sihrb008,tksrb151,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn RBF151,,. ./.profile 1>/dev/null 2>&1;nohup rtprio 100 ART_AMC_Start_ksh -i RBF151 -b olcServer -m "pm olc" -t olc -n RATER -x Y &,,ps -fu \$LOGNAME | grep 'olcServer -n RBF151'|grep -vgrep                                                                                 
SYNC,SYNC151,sihrb008,tksrb151,. ./.profile 1>/dev/null 2>&1;stop_olc_dmn SYNC151,,. ./.profile 1>/dev/null 2>&1;nohup ART_AMC_Start_ksh -i SYNC151 -b olcServer -m "pm olc" -t olc -n RATER -x N &,,ps -fu \$LOGNAME | grep 'olcServer -n SYNC151'|grep -vgrep

so i want to execute a logic which will handle this type of request and get data from given CSV file.
i hope , someone can give an idea.
let me know if more details are required

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.


---------- Post updated 01-13-12 at 02:28 AM ---------- Previous update was 01-12-12 at 03:52 AM ----------

i am sorry , cant see video .i see blue screen only and no video, . well i dont have any script code , i h=just provided file and my requirement .

Last edited by radoulov; 01-11-2012 at 05:23 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Output not coming as desired.

Hi guys. I have a file containing some hosts and their IPs. host host1 192.168.2.10 host host2 192.168.2.11 host host3 192.168.2.12 I am writing a script where I want to print these values in 1 line. My script looks like RUNTIME_NODE=`cat hosts.properties | grep host` for i in... (7 Replies)
Discussion started by: Junaid Subhani
7 Replies

2. Shell Programming and Scripting

Save output of updated csv file as csv file itself, part 2

Hi, I have another problem. I want to sort another csv file by the first field. result.csv SourceFile,Airspeed,GPSLatitude,GPSLongitude,Temperature,Pressure,Altitude,Roll,Pitch,Yaw /home/intannf/foto5/2015_0313_090651_219.JPG,0.,-7.77223,110.37310,30.75,996.46,148.75,180.94,182.00,63.92 ... (2 Replies)
Discussion started by: refrain
2 Replies

3. Shell Programming and Scripting

Save output of updated csv file as csv file itself

Hi, all I want to sort a csv file based on timestamp from oldest to newest and save the output as csv file itself. Here is an example of my csv file. test.csv SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0739.JPG,2015:02:17 11:32:21 /home/intannf/foto/IMG_0749.JPG,2015:02:17 11:37:28... (10 Replies)
Discussion started by: refrain
10 Replies

4. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies

5. UNIX for Dummies Questions & Answers

Handling Comma in string values in a CSV file

Hi have a comma separated file which has numeric and string columns. String columns are quoted and can have comma in between the quotes. How to identify the columns with FS ="," sample records"prabhat,kumar",19,2000,"bangalore,India" In awk it should be$1 = prabhat,kumar $2=19 $3=2000... (9 Replies)
Discussion started by: prabhat.diwaker
9 Replies

6. 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

7. 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

8. 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

9. Shell Programming and Scripting

Using awk/sed in handling csv file.

Please study the below script and the output Script: echo "Minimum ${host} ${process} response time=${min} ms" >> ${OUTDIR}/${OUTFILE}; echo "Maximum ${host} ${process} response time=${max} ms" >> ${OUTDIR}/${OUTFILE}; echo "Average ${host} ${process} response time=${avg} ms" >>... (0 Replies)
Discussion started by: ajincoep
0 Replies

10. 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
Login or Register to Ask a Question