LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 09:21 AM   #1
hoi
Member
 
Registered: Jun 2013
Posts: 32

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 09:23 AM.
 
Old 03-19-2016, 09:27 AM   #2
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
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, 09:41 AM   #3
hoi
Member
 
Registered: Jun 2013
Posts: 32

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:	42
Size:	14.6 KB
ID:	21196  
 
Old 03-19-2016, 10:06 AM   #4
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
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, 09:37 PM   #5
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
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 09:52 PM.
 
Old 03-19-2016, 11:48 PM   #6
hoi
Member
 
Registered: Jun 2013
Posts: 32

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, 02:51 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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, 02:58 AM   #8
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
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, 09:07 AM   #9
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Fair call
 
  


Reply

Tags
awk, bash, linux, sed, unix



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:28 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
Open Source Consulting | Domain Registration