ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi Druuna, grail, colucix ....I need some more help....
They gave me some more data is a slightly different format:
01/02/09 18:03:03 1.280550 1.281550
01/02/09 18:23:20 1.280570 1.281570
01/02/09 18:23:24 1.280270 1.281270
01/02/09 18:53:53 1.279970 1.280970
01/02/09 18:54:10 1.279810 1.280810
01/02/09 18:54:11 1.279780 1.280780
01/02/09 18:54:11 1.279770 1.280770
01/02/09 19:04:45 1.279500 1.280500
01/02/09 19:05:22 1.279500 1.280500
01/02/09 19:05:58 1.279500 1.280500
So now this data has the '/' character too in the first column. If I use:
awk -F"[ :]" '{ print $1 $2 $3 $4","$5","$6",SYM" }' infile.txt > newfile.txt
Then it only removes the ':' and not the '/' character. I tried something like:
awk -F"[ :,/]" '{ print $1 $2 $3 $4","$5","$6",SYM" }' infile.txt > newfile.txt, but it is not working.
Please let me know how I can get the above data in the following format:
090102180303,1.280550,1.281550,SYM
So in the first column I need to get rid of the '/' character and get the year first 09 then the month 01 and then the date 02. Then I need to remove both the separators, remove the space between first and second column. Eg.
01/02/09 18:03:03 1.280550 1.281550
to:
090102180303,1.280550,1.281550,SYM
Hoping to hear back soon. Thank you for your help.
Thanks alot pixellany, it works well but just a slight problem. I am getting a space after each ','. So I am getting something like:
090102180303, 1.280550, 1.281550, SYM
instead of:
090102180303,1.280550,1.281550,SYM
Can you please suggest how I can take care of this issue?
Hi shakes ... whilst it is obvious that you are new to the likes of awk and sed you really are supposed to try and learn from the information given, otherwise you will just be back when you get
stuck again.
Anyhoo, if you look at the sed provided by pixellany you will see a space after each comma that is replacing items like a space or end of line.
Personally I would just leave it all in awk:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.