LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-01-2011, 07:25 PM   #1
magnusemail
LQ Newbie
 
Registered: Sep 2011
Posts: 1

Rep: Reputation: Disabled
Question Issues with using SED to remove / in date field


Hello,

I would appreciate aan answer on the correct syntex to remove the / in a csv file in which each date field is in the format 31/08/2011 and is need in format 31082011

the csv file has multiple rows, with each row having a starting date column to which I need to remove the / , I think I should use SED to to this, however perhaps I have not undertstood how to escape the / to be able to make it work?

Many thanks
Magnus
 
Old 09-01-2011, 08:14 PM   #2
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware 14.2
Posts: 2,815
Blog Entries: 1

Rep: Reputation: 261Reputation: 261Reputation: 261
Code:
sed -i 's@/@@g' filename.csv
Should work.
 
1 members found this post helpful.
Old 09-01-2011, 10:10 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
Be careful with the above if there are slashes in other fields as well.
 
Old 09-01-2011, 10:29 PM   #4
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware 14.2
Posts: 2,815
Blog Entries: 1

Rep: Reputation: 261Reputation: 261Reputation: 261
Quote:
Originally Posted by grail View Post
Be careful with the above if there are slashes in other fields as well.
Good point. I was assuming only the date had slashes. This will delete only the first two slashes in the file
Code:
sed -e 's@/@@2' -e 's@/@@1' filename.csv > newfilename.csv
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help, converting date format in a comma separated field! mgsmith7475 Programming 2 04-09-2010 11:34 AM
Sed / Awk / removing chars from field 5 only webs Linux - Newbie 11 10-31-2009 03:46 AM
dpkg-scanpackage omits Date: field qriopeur Debian 11 06-08-2009 10:32 AM
Error : Truncating oversized date field kumar_79v Linux - Server 1 07-08-2008 01:47 AM
replaced variable field within shell script using sed hamimi Linux - Newbie 2 05-28-2008 08:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration