![]() |
sponsored links |
|
|
sponsored links
|
|
1
24th April 22:17
External User
Posts: 1
|
Hey all, not a Debian specific question. I am working with some CSV files.
Daily extracts. I was able to combine them all with cat, then yank out the records I needed and popped then in a smaller file using grep. Finally yanked duplicates using sort < file | uniq -d Now comes the hard part. Each record begins with the date and hour. When I graph a month's worth of data, the graphs get nuts, so I want to remove specific entries from each line. Specifically, I want to replace the entry with a comma. A sample of the file is below: Date,TargetName ifIndex IfDescr,AvgIn,AvgOut,MaxIn,MaxOut 10/17/2003 0:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),0.12,0.04,0.18,0.05 10/17/2003 1:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),0.24,0.09,0.26,0.16 10/17/2003 2:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),0.22,0.09,0.33,0.12 10/17/2003 3:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),0.08,0.05,0.11,0.06 10/17/2003 4:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),0.16,0.05,0.23,0.08 10/17/2003 5:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),0.18,0.07,0.31,0.08 10/17/2003 6:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),0.58,0.07,0.94,0.09 10/17/2003 7:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),1.32,0.05,1.57,0.06 10/17/2003 8:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),2.11,0.03,2.76,0.04 10/17/2003 9:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),2.44,0.05,3.36,0.05 10/17/2003 10:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),2.15,0.03,2.4,0.04 10/17/2003 11:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),1.97,0.04,2.07,0.04 10/17/2003 12:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),1.73,0.04,2.02,0.04 10/17/2003 13:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),2.09,0.05,2.88,0.08 10/17/2003 14:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),2.03,0.04,2.69,0.05 10/17/2003 15:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),1.53,0.04,1.72,0.04 10/17/2003 16:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),2.64,0.04,3.98,0.06 10/17/2003 17:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),2.04,0.06,2.69,0.07 10/17/2003 18:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),0.82,0.12,1.16,0.22 10/17/2003 19:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),0.2,0.05,0.28,0.08 10/17/2003 20:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),0.03,0.03,0.06,0.03 10/17/2003 21:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),0.07,0.47,0.08,0.75 10/17/2003 22:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),0.05,0.03,0.08,0.05 10/17/2003 23:00,10.2.1.101 127 10/100 utp ethernet (cat 3/5),0.03,0.03,0.05,0.05 How would I replace 10/17/2003 1:00 with a , ? I need to hit each day of the month, and I only want to show the text for 10/**/2003 0:00, 8:00, 16:00. The rest I want to use a , to show an empty cell. -- To UNSUBSCRIBE, email to debian-user-request@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
2
25th April 08:44
External User
Posts: 1
|
Not clear what you want, I am guessing you want to remove the date and time
leaving behind just a comma. Just one of the many ways... | sed 's/[^,]*//' If you want to keep the date and time for the first entry(line), but strip off all the remaining date and times, then... | sed '2,$s/[^,]*//' Cheers, Ashish. -- To UNSUBSCRIBE, email to debian-user-request@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
4
26th April 05:29
External User
Posts: 1
|
Hi Bruce,
awk is a quite powerful tool for that sort of thing. Its basic structure is /pattern/ {action} i. e. it reads a line from the input file and if the line matches /pattern/ it does {action} (e. g. write the line to output or write "," instead). It is described very well in the manpage. HTH -- Joachim Fahnenmüller # Hi! I'm a .signature virus. Copy me into # your ~/.signature to help me spread! -- To UNSUBSCRIBE, email to debian-user-request@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
5
26th April 05:29
External User
Posts: 1
|
----- Original Message -----
From: "Joachim Fahnenmueller" <JFahnenmueller@t-online.de> To: "Debian-User" <debian-user@lists.debian.org> Sent: Friday, November 14, 2003 11:42 AM Subject: Re: Text processing help (sed?) /pattern/ it Thanks Joachim - I'll check out the manpage. -- To UNSUBSCRIBE, email to debian-user-request@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|