LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 12-12-2009, 03:36 PM   #1
pvictory1
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Rep: Reputation: 0
Unhappy Field positioning in unix for a single output file


Quote:
Hi, Is there a any other options beside using \t or a blank space for an output file? The problem I'm having is I'm converting F to C and C to F and the program works just fine but when you view the out put file one of the lines has three four digit numbers and it is keeps shifting the numbers over. So is there a way to make the numbers left justified or centered?
Quote:
my input file looks like this.
1
8
22
43
89
283
120
212
1043
100
287
Quote:
My line that is in question is
Code:
echo -e "\t$Temp \t\t  \t  $f  \t\t\t\t $Temp  \t\t\t\t   $c" >> output_file
Quote:
My out put looks like this
Code:
    Centigrade    Fahrenheit  Fahrenheit    Centigrade 
----------------  ----------  ----------    ----------
         1           33          1             -17
----------------  ----------  ----------    ----------
         8           46          8             -13
----------------  ----------  ----------    ----------
        22           71          22             -5
----------------  ----------  ----------    ----------
        43           109         43              6
----------------  ----------  ----------    ----------
        89           192         89             31
----------------  ----------  ----------    ----------
        283          541         283            139
----------------  ----------  ----------    ----------
        120          248         120            48
----------------  ----------  ----------    ----------
        212          413         212            100
----------------  ----------  ----------    ----------
        1043         1909             1043              561
----------------  ----------  -----------   ----------
        100          212         100            37
----------------  ----------  -----------   ----------
        287          548         287            141
----------------  ----------  -----------   ----------
 
Old 12-12-2009, 03:46 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

Perhaps you are looking from something like printf.
In this example (untested) each integer is given 9 spaces in which it is right justified.
Code:
printf ' %9i %9i %9i %9i\n' $Temp $f $Temp $c >> output_file
Have a look at the man page for more information.

Cheers,

Evo2.
 
  


Reply



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] awk or sed to use CSV as input and XML as template and output to a single file bridrod Linux - Newbie 6 03-13-2012 07:00 PM
LXer: Simple Script To List Groups In Passwd File Output On Linux And Unix LXer Syndicated Linux News 0 04-21-2009 07:20 AM
awk run script on field before output Geneset Programming 3 08-26-2008 04:59 AM
Filesystem which allows manual file positioning? Tyco Linux - General 5 10-18-2007 11:36 PM
Is there a way in Linux/Unix bash to turn off output or redirect to a file jimwelc Linux - Newbie 6 01-06-2005 03:56 AM

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

All times are GMT -5. The time now is 06:45 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