LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Closed Thread
  Search this Thread
Old 01-11-2018, 04:11 AM   #1
SerZKO
LQ Newbie
 
Registered: Jan 2018
Distribution: SuSE
Posts: 6

Rep: Reputation: Disabled
Problem reformating a file


I have a problem with file which was reformated during some operation and looks like this:
Code:
18450 0600060009                       25  0 768188519       768188519       0030020124 000 000   10
77019           73587                       25  0 73165           730740506       0160100051 029 000
74049                                       25  0 73950                           1040030047 030 000
14048           14048                       25  0 11833           11833                      022 000
18450 0600060027                       25  0 709948778       709948778       0010030064 000 000   10
                73330                       25  0 0050312875      77020                      000 000
18450 0600040020                       25  0 703820853       703820853       0030020125 000 000   10
And I need it to look like this

Code:
18450 0600060009                       25  0 768188519       768188519       0030020124 000 000   10
77019      73587                       25  0 73165           730740506       0160100051 029 000
74049                                  25  0 73950                           1040030047 030 000
14048      14048                       25  0 11833           11833                      022 000
18450 0600060027                       25  0 709948778       709948778       0010030064 000 000   10
           73330                       25  0 0050312875      77020                      000 000
18450 0600040020                       25  0 703820853       703820853       0030020125 000 000   10
What happened was that column B has shifted 5 places to the right.
I've tried to solve it with a simple
Code:
 while read do printf
but the problem is how to read empty spaces into the variable. I've tried with perl and substr, but it doesn't really work as it shoul. It looks like sed would be a perfect tool for that, but I just don't know how to do it as any of column where number of digits is greater then 3 can be empty. Any help appreciated.
 
Old 01-11-2018, 02:10 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

Replies to this thread have been merged into your other thread and this thread is now closed as a duplicate.
 
  


Closed Thread



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
[SOLVED] Problems reformating file SerZKO Programming 15 01-12-2018 08:21 AM
Thinking of Reformating Zentharus Ubuntu 10 04-02-2012 03:56 PM
reformating iPod goens Linux - Hardware 2 04-10-2006 01:31 PM
need help reformating hdd! thrustan Linux - Hardware 1 03-10-2005 11:25 AM
Reformating linux DivisionByZero Linux - Newbie 4 08-31-2004 03:56 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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