LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Changing data format using sed and Xargs command (https://www.linuxquestions.org/questions/linux-newbie-8/changing-data-format-using-sed-and-xargs-command-4175471283/)

Hariesh08 07-29-2013 01:59 AM

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,

syg00 07-29-2013 02:17 AM

You show us what you did to solve this, and what you did to analyse any errors, and we might try and help.

Hariesh08 07-29-2013 02:32 AM

Quote:

Originally Posted by syg00 (Post 4998709)
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

SAbhi 07-29-2013 03:17 AM

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 ?


All times are GMT -5. The time now is 01:16 AM.