LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 03-19-2016, 10:21 AM   #1
hoi
LQ Newbie
 
Registered: Jun 2013
Posts: 27

Rep: Reputation: Disabled
decorate data file


I have a data file like this..

0.00000 -0.06291770 -0.00130211
0.01010 0.00000718 0.00000718
0.02020 0.00001363 0.00001363

I want to print the above file like this...

0.00000 -0.06291770 -0.00130211
0.01010 0.00000718 0.00000718
0.02020 0.00001363 0.00001363

Thanks in advance

Last edited by hoi; 03-19-2016 at 10:23 AM.
 
Old 03-19-2016, 10:27 AM   #2
hydrurga
Senior Member
 
Registered: Nov 2008
Distribution: Linux Mint 18 MATE
Posts: 1,212

Rep: Reputation: 341Reputation: 341Reputation: 341Reputation: 341
Quote:
Originally Posted by hoi View Post
I have a data file like this..

0.00000 -0.06291770 -0.00130211
0.01010 0.00000718 0.00000718
0.02020 0.00001363 0.00001363

I want to print the above file like this...

0.00000 -0.06291770 -0.00130211
0.01010 0.00000718 0.00000718
0.02020 0.00001363 0.00001363

Thanks in advance
Those two look pretty similar to me. Can you explain what it is you are you trying to do, and what code you have written so far to try and achieve it.

You should place any code or output within CODE brackets (see the # symbol on the editing toolbar).
 
Old 03-19-2016, 10:41 AM   #3
hoi
LQ Newbie
 
Registered: Jun 2013
Posts: 27

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by hoi View Post
I have a data file like this..

0.00000 -0.06291770 -0.00130211
0.01010 0.00000718 0.00000718
0.02020 0.00001363 0.00001363

I want to print the above file like this...

0.00000 -0.06291770 -0.00130211
0.01010 0.00000718 0.00000718
0.02020 0.00001363 0.00001363

Thanks in advance
I have attached my question.
Attached Thumbnails
Click image for larger version

Name:	Screenshot-26.png
Views:	23
Size:	14.6 KB
ID:	21196  
 
Old 03-19-2016, 11:06 AM   #4
hydrurga
Senior Member
 
Registered: Nov 2008
Distribution: Linux Mint 18 MATE
Posts: 1,212

Rep: Reputation: 341Reputation: 341Reputation: 341Reputation: 341
Quote:
Originally Posted by hoi View Post
I have attached my question.
What programming language or shell scripting language are you using, and what code you have written so far to try and achieve it?
 
Old 03-19-2016, 10:37 PM   #5
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,430

Rep: Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349
Perhaps
Code:
sed 's/ -/-/g' <<yourfile>>
If that is what you want, redirect output to a new file, or else use the -i option to sed.

PS - When posting at LQ, wrap your text in [CODE][/CODE][ tags so that spaces are preserved.

Last edited by allend; 03-19-2016 at 10:52 PM.
 
Old 03-20-2016, 12:48 AM   #6
hoi
LQ Newbie
 
Registered: Jun 2013
Posts: 27

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by allend View Post
Perhaps
Code:
sed 's/ -/-/g' <<yourfile>>
If that is what you want, redirect output to a new file, or else use the -i option to sed.

PS - When posting at LQ, wrap your text in [CODE][/CODE][ tags so that spaces are preserved.

I could not think this way though I have used this command many times. Thank you very much.
 
Old 03-20-2016, 03:51 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,252

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
I am surprised this is the solution you were after, as the output now looks like:
Code:
0.00000-0.06291770-0.00130211 
0.01010 0.00000718 0.00000718 
0.02020 0.00001363 0.00001363
Here the lines with a dash look like ranges compared to separate columns like the other lines.

Or maybe this hint helped you to solve the question yourself, if so, please show your solution?
 
Old 03-20-2016, 03:58 AM   #8
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,430

Rep: Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349
From the picture in post #3, the original data appears to be
Code:
0.00000   -0.06291770   -0.00130211
0.01010   0.00000718   0.00000718
0.02020   0.00001363   0.00001363
which has additional spaces compared to that which the OP posted.
 
Old 03-20-2016, 10:07 AM   #9
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,252

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Fair call
 
  


Reply

Tags
awk, bash, linux, sed, unix


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
Extract data from a file using bash then use part of that data to rename the input fi mfarch99 Linux - Newbie 11 09-05-2014 11:51 AM
how to make marco decorate the windows in MATE while using compiz-fusion? sljunkie Linux - Software 0 08-01-2012 08:14 AM
[SOLVED] How to tell compiz NOT to decorate a specific window type drumvudu Linux - General 5 10-26-2011 11:02 AM
Over my head with this problem - Access the data in .fbd data file BobNutfield Linux - Server 3 02-20-2011 02:48 PM
Decorate/Decorations in Openbox naitscho Linux - Software 0 07-27-2005 01:28 PM


All times are GMT -5. The time now is 12:57 PM.

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