LinuxQuestions.org
Register a domain and help support LQ
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 07-29-2013, 02:59 AM   #1
Hariesh08
LQ Newbie
 
Registered: Jul 2013
Posts: 2

Rep: Reputation: Disabled
Changing data format using sed and Xargs command


I have a file below. i want to change into below format.

bash-3.00$ cat test1.txt
37 "28/Jul/2013" 23 2121 0
37 "28/Jul/2013" 27 103463 0
37 "28/Jul/2013" 8 125667 0

Changing format:
37 "2013-07-28" 23 2121 0
37 "2013-07-28" 27 103463 0
37 "2013-07-28" 8 125667 0

Let me know the Command to use to change the format.

Thanks,
 
Old 07-29-2013, 03:17 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,832

Rep: Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820
You show us what you did to solve this, and what you did to analyse any errors, and we might try and help.
 
Old 07-29-2013, 03:32 AM   #3
Hariesh08
LQ Newbie
 
Registered: Jul 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
You show us what you did to solve this, and what you did to analyse any errors, and we might try and help.
I tried this command to get the result, but getting error. Please help on this..


sed 's/\//-/g' test1.txt | xargs -0 date '+%F %T' -d
 
Old 07-29-2013, 04:17 AM   #4
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 664

Rep: Reputation: 80
why would you need to change the format, you could rather change the / with - and preserve the current format for date with just half line of code ?
hope this is not a Homework. :P


Quote:
sed 's/\//-/g' test1.txt | xargs -0 date '+%F %T' -d
incorrect use of xargs for sure. So what error did you got ?

Last edited by SAbhi; 07-29-2013 at 04:20 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Renaming file extensions using find-xargs-sed Rohit_4739 Linux - Newbie 11 01-31-2013 04:23 PM
Problem with get data using sed command nanthagopal Programming 3 11-23-2012 10:21 AM
Problem using sed with variable created using xargs - unterminated error wrankin Programming 5 11-14-2011 08:53 PM
Traverse the file system and Rename (xargs or sed?) sahil.jammu Linux - General 19 05-25-2011 11:15 AM
sed command to replace date format 2007/01/22 with 070122? johnpaulodonnell Linux - Newbie 3 01-23-2007 08:29 AM


All times are GMT -5. The time now is 06:13 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration