Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 08-04-2008, 05:14 PM   #1
LQ Newbie
Registered: Aug 2008
Posts: 2

Rep: Reputation: 0
GNUplot / sed help

Hey guys, first post .

I'm working with GNUplot and some experimental data that I need to plot. Unfortunately, some of the data is comma separated values, and some is tab/six space separated (I thought it was tabbed but when I go into a text editor I can space six times to remove all the space so I assume that's not a tab. I don't know any more sophisticated way of determining that.)

Long story short, I can set the data delimiter within GNUplot using "set datafile separator ","" or use "\t" for a tab, but I can't do that in the middle of a plot, to my knowledge. So if I'm going "plot "data.csv" using 1:2, "" using 1:2" that will error out if I set either , or \t as the separator, and if I try to use the "set datafile separator" command in the middle of "plot" that errors out too.

So I want to use sed to just change the few spaced delimiter files to CSV's. "sed -i '/s/[six spaces]/,/g'" doesn't work.

How can I represent spaces?

Thanks for your time,
Old 08-04-2008, 05:23 PM   #2
Senior Member
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
It's not working because you have a typo. It should be:

sed -i 's/[six spaces]/,/g'

Old 08-05-2008, 10:02 AM   #3
LQ Newbie
Registered: Aug 2008
Posts: 2

Original Poster
Rep: Reputation: 0

Splendid... thank you so much!
Old 08-05-2008, 02:41 PM   #4
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677
You can also use the "tr" (translate) command to remove extra spaces and replace the remaining space with a comma.
tr -s ' ' ',' < >


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
gnuplot 4.0.0 ines Linux - Software 1 04-28-2005 03:26 PM
Gnuplot allycavs Linux - Software 5 02-04-2005 08:31 AM
need help for gnuplot eph Linux - Newbie 1 08-23-2004 09:41 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 07:12 AM
about gnuplot Rex_chaos Linux - Software 0 09-25-2003 09:50 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:25 AM.

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