Append data to new row in CSV file every day


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Append data to new row in CSV file every day
# 1  
Old 06-25-2012
Append data to new row in CSV file every day

Hi All

I will run the same script every day in corn and output should go to same CSV file but in different row with dates on it. Below is my example in attached format.

Script i am using to collect switch port online

Code:
DATE=`date '+%d-%m-%y'`
for f in `cat /home/user/switch-ip/switch-ip-test.txt`
do
     echo $f-[$DATE] >> /home/user/switch-ip/switch-nolight.csv
     plink -ssh -v chrrbs@$f -pw secure01 switchshow |grep "No_Light" >> /home/user/switch-ip/switch-nolight.csv
done

Moderator's Comments:
Mod Comment Please use code tags, not quote-tags, thanks!

Last edited by zaxxon; 06-25-2012 at 11:04 AM.. Reason: code tags, see PM
# 2  
Old 06-25-2012
So... what is the problem? What does it do right now?

Without seeing the input data, we cannot possibly help you. What does plink here output (before grep)? And why are you grepping for No_Light?

Also, please read Useless Use of Backticks before your own bugs come back to haunt you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Python script to run multiple command and append data in output csv file

Experts, I am writing a script and able to write only small piece of code and not able to collect logic to complete this task. In input file have to look for name like like this (BGL_HSR_901_1AG_A_CR9KTR10) before sh iss neors. Record this (BGL_HSR_901_1AG_A_CR9KTR10) in csv file Now have to... (0 Replies)
Discussion started by: as7951
0 Replies

2. Shell Programming and Scripting

Row Count in .csv file

Hi, I have to find the count of rows starting with "E," in given a.csv file . Sample Data File. E,2333AED,A,MC3,25,31-MAY-18 E,2333AED,A,MC3,25,31-MAY-18 CYMC3 25AED 0000 E,2333CZK,A,MC3,25,31-MAY-18 CYMC3 25CZK 0000 E,2333EUR,A,MC3,25,31-MAY-18... (3 Replies)
Discussion started by: Prabhakar Y
3 Replies

3. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

4. Shell Programming and Scripting

Read line from the file and append it to each row

Hi All, We have a file in the following format: 0.010000 $ ITI 11 LV2 $ 40456211 $ 0.135000 $ ITI 11 LV1 $ 40512211 $ 1.215600 $ ITI 11 ITI3 $ 41406211 $ 24/05/2014 14:05:02 0.030000 $ ITI 11 LV2 $ 40456211 $ ... (3 Replies)
Discussion started by: gauravsinghal79
3 Replies

5. UNIX for Dummies Questions & Answers

append column and row header to a file in awk script.

Hi! Is there a way to append column and row header to a file in awk script. For example if I have Jane F 39 manager Carlos M 40 system administrator Sam F 20 programmer and I want it to be # name gend age occup 1 Jane F 39 manager 2 Carlos M ... (4 Replies)
Discussion started by: FUTURE_EINSTEIN
4 Replies

6. Shell Programming and Scripting

I want to append data to same .csv file.

I have a script which has to be scheduled to run 3 times a day. My script picks the required fields from logfile and stores the data in a.csv file. Sample data. my logfile contain: 0097A,0374D,100903,1519,00000606191 0097A,C88RA,100903,0724,00000606105 So the output of first execution... (3 Replies)
Discussion started by: shrima.pratima
3 Replies

7. Shell Programming and Scripting

Append Second Row to First Row @ end in a file

Hi I want to append line 2n to 2n-1 line where n=1...LastLine in my file. eg: Actual File: Hello Everyone Welcome TO Unix I need Your help Required File: HelloEveryone WelcomeTO Unix I needYour help (5 Replies)
Discussion started by: dashing201
5 Replies

8. Shell Programming and Scripting

Append Header in CSV file

Hi, I create a csv file and the output looks like below Arun,E001 Sathish,E003 Now i need to include the below header and the output should like below Name,Number Arun,E001 Sathish,E003 Please guide me. Thanks (4 Replies)
Discussion started by: Sekar1
4 Replies

9. Shell Programming and Scripting

to append data in a single row

Hi all, I need a logic in UNIX to append contents of a file in same row, where the original contents are found one below the other. For example. My i/p file contains: “user1”,”employee1”,”04/28/2009” “5678” “78” “user2”,”employee2”,”04/30/2009” I want my output... (8 Replies)
Discussion started by: Sgiri1
8 Replies

10. Shell Programming and Scripting

How to insert data befor some field in a row of data depending up on values in row

Hi I need to do some thing like "find and insert before that " in a file which contains many records. This will be clear with the following example. The original data record should be some thing like this 60119827 RTMS_LOCATION_CDR INSTANT_POSITION_QUERY 1236574686123083rtmssrv7 ... (8 Replies)
Discussion started by: aemunathan
8 Replies
Login or Register to Ask a Question