sed should cut seconds


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed should cut seconds
# 1  
Old 05-18-2012
sed should cut seconds

Hi!

I need help to modify a comma-sep. file.
I tried to cut the secons of a timestamp.
...
Code:
11,05/15/12,13:20:00,Raw Counts,58313,5280,6967
13,05/15/12,13:40:00,Raw Counts,70637,6592,8648

...

it should be:
Code:
11,05/15/12,13:20,Raw Counts,58313,5280,6967
13,05/15/12,13:40,Raw Counts,70637,6592,8648

alternativly - the information Raw Counts is obsolet and i does not really use it.
Code:
11,05/15/12,13:20,58313,5280,6967
 13,05/15/12,13:40,70637,6592,8648

i tried to solve it with sed, but it will not work.
Code:
sed 's/(:[0-5][0-9],)/\,/'  file.csv

can you please give me a hint ?

Thanks in advance!

Last edited by Scrutinizer; 05-18-2012 at 01:04 AM.. Reason: Some more code tags
# 2  
Old 05-18-2012
Code:
sed 's/:[0-5][0-9],Raw Counts//' file.csv

This User Gave Thanks to balajesuri For This Post:
# 3  
Old 05-18-2012
Quote:
Originally Posted by balajesuri
Code:
sed 's/:[0-9]\{2\},Raw Counts//' file.csv

Hey, thats great - is working properly.

Thanks a lot!!
IMPe
# 4  
Old 05-18-2012
You do not need the brackets and they are seen as real brackets, so that is why there is no match.
Code:
sed 's/:[0-5][0-9],/,/'

This User Gave Thanks to Scrutinizer For This Post:
# 5  
Old 05-18-2012
You were very close with your original try, just dont bracket expression and backslash on comma is unnecessary .

Code:
sed 's/:[0-5][0-9],/,/' file.csv

This User Gave Thanks to Chubler_XL For This Post:
# 6  
Old 05-18-2012
Thank you for helping me with sed. A good chance for me to become more familiar with sed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ping - cut and sed - problem

How can I get the following result of the "ping" command? Example: root@OpenWrt:~# ping google.com -c1 | sed -n 1p PING google.com (216.58.210.14): 56 data bytes How can I get the data only in the range of ()? The result of what I want to get it: 216.58.210.14 Please use code... (4 Replies)
Discussion started by: andrewxxx
4 Replies

2. Shell Programming and Scripting

sed cut columns

hello everyone ! i face the following problem as i use sed to ignore some columns of an output. the command i use is sed 's/^\(*\) \(*\).*/\1 \2/' as i only want the 2 first columns the command finger returns the problem is that for some lines the results are fine but for other lines... (8 Replies)
Discussion started by: vlm
8 Replies

3. Shell Programming and Scripting

sed and cut behaving differently

I have attached a file with few records. First 2 characters of each record are binary characters. I can remove it by and it works fine. But is behaving differently and removing more than expected characters. Can someone help me in accomplishing it through sed? Thanks in advance. (13 Replies)
Discussion started by: amicon007
13 Replies

4. UNIX for Dummies Questions & Answers

How to use cut or sed for my little script.

Hello people, I have a little script that has to compare some files (exe files)... so i find all the files in the given paths (2 paths) and it generates 2 txt files (named 1.txt and 2.txt, they have to be identical) i need to have a little IF function to compare the 2 files and see if they are... (2 Replies)
Discussion started by: valiadi
2 Replies

5. Shell Programming and Scripting

Text cut between two $ in a line with SED

Let's say I have a line like that: I want to cut out numbers between two $ including $s. The result should be like that: I am so-newbei. I am non-stop reading about SED since yesterday and not a programmer. I know that it is a short period, thus maybe I had overlooked something. I... (4 Replies)
Discussion started by: l_p
4 Replies

6. Shell Programming and Scripting

cut in sed/awk

Hi Can i have an example where i should be able to cut columns (like for eg cut -c 1-3) in sed or awk. Regards Dhana (12 Replies)
Discussion started by: dhanamurthy
12 Replies

7. Shell Programming and Scripting

Help in SED and CUT.

Hi I have a file. In Each and every line, i want to cut the position from 130 to 134 and need to check if it is XXXX then i need to replace with YYYY (Only from 130 to 134). Your help is very much appriciated. (4 Replies)
Discussion started by: senthil_is
4 Replies

8. Shell Programming and Scripting

cut sed grep or other?

Hi Is there a way to cut the last two characters off a word or number given that this word or number can be of varying length? I have tried something like TEST=`echo $OLD | cut -c 1-5` where $OLD is a variable containing a number like 1234567 which gives a result of 12345. This is fine... (4 Replies)
Discussion started by: rleebife
4 Replies

9. Shell Programming and Scripting

SED and Cut question

I am trying to cut and delete using sed and redirect back into the file. This is not working write. When testing the script, it hangs. Any idea what I am doing wrong here. ################ Reads the input file to cut volumes for returns and CUT_ERVTAPE_FILE() { echo "working on cut... (2 Replies)
Discussion started by: gzs553
2 Replies

10. UNIX for Dummies Questions & Answers

cut vs. sed vs. awk ?

hi again...need new help guys:p the file contains following infos... users/abc/bla1.exe newusers/defgh/ik/albg2.exe users2/opww/ertz/qqwertzu/rwerwew.exe how to get the file content into... users/abc/ newusers/defgh/ik/ users2/opww/ertz/qqwertzu/ with... you can erase the... (5 Replies)
Discussion started by: svennie
5 Replies
Login or Register to Ask a Question