LinuxQuestions.org
Help answer threads with 0 replies.
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, 04: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, 04:46 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
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


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
[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 08:00 PM
LXer: Simple Script To List Groups In Passwd File Output On Linux And Unix LXer Syndicated Linux News 0 04-21-2009 08:20 AM
awk run script on field before output Geneset Programming 3 08-26-2008 05:59 AM
Filesystem which allows manual file positioning? Tyco Linux - General 5 10-19-2007 12:36 AM
Is there a way in Linux/Unix bash to turn off output or redirect to a file jimwelc Linux - Newbie 6 01-06-2005 04:56 AM


All times are GMT -5. The time now is 08:43 AM.

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