Sponsored Content
Full Discussion: awk to indent file outout
Top Forums Shell Programming and Scripting awk to indent file outout Post 302685145 by SkySmart on Friday 10th of August 2012 09:39:29 PM
Old 08-10-2012
Quote:
Originally Posted by Don Cragun
In your input the second field is sometimes "===" and sometimes "====", but you show "====" on all of your output lines. Assuming you want to maintain what is in the input fields and just align the output, the following might work:
Code:
awk '   {
        f1[NR]=$1
        f2[NR]=$2
        f3[NR]=$3
        if (length($1) > max1) max1=length($1)
        if (length($2) > max2) max2=length($2)
}
END     {
        fmt=sprintf("%%-%ds %%-%ds %%s\n",max1,max2)
        for (i=1; i<=NR; i++) printf(fmt,f1[i],f2[i],f3[i])
}' file...

but I would be nervous about doing this for "large" input files.
sorry about that. i meant to have all of them to be "===="

but why would u be nervous about doing this for large input files? is there a better solution?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Auto indent in vi

Hi, I use vi for my text editing. Is there a way to use smart indentation? that is when adding a '{' or '}' that the editor will jump and advance, or any other thing like that? thanks (1 Reply)
Discussion started by: sierra_aar
1 Replies

2. UNIX for Dummies Questions & Answers

vim indent

I know this is not a unix question but I also know that many of you use vim editor every day. So hoping to get some help, here it goes: How can I change my vim config file so that the indentations while c programming take 4 spaces instead of 8? I want the change to apply any further uses of... (4 Replies)
Discussion started by: Virtuosso
4 Replies

3. UNIX for Dummies Questions & Answers

vi auto indent whole file at once

Hi, I'm working on a big project and all the CPP and header files are in mess with respect to indentation. I would like to indent whole file(s) at once (like ctrl-shift-f in eclipse). Is there anybody who knows how to do that in vi/vim? thanks (2 Replies)
Discussion started by: SaTYR
2 Replies

4. Shell Programming and Scripting

creating/using libraries Perl...blank outout?

Good morning!! Im trying to create a script that should get a list of numbers from the user (using STDIN or a list of arguments), and call my library function. #!use/bin/perl require 'my-lib.pl'; @userArray = <STDIN>; while() { chomp; last if ! /\d/; push(@userArray,&_); }... (2 Replies)
Discussion started by: bigben1220
2 Replies

5. UNIX for Dummies Questions & Answers

gvim: how to set new indent to a file (tabsize)

Hi, I'm working with gvim, and opened an old file for editing. the file 'older' indents are diffrent from the current and I wish to set the file to cahnge the whole file to the new indenting setting at once. How can it be done? thnx. (0 Replies)
Discussion started by: cvs_eng
0 Replies

6. Shell Programming and Scripting

How to indent the file lines using vi?

Every now and then I have to indent the lines in my script to 4 space characters. I generally do it line by line. Is there an automated command in vi using which I can indent some set of lines to desired number of space characters in one go. (2 Replies)
Discussion started by: paragkalra
2 Replies

7. Shell Programming and Scripting

getting requestName from xml outout in log file

hi all, i was wondering if there is an easy and smart way of greping for requestname (in bold below) from xml output from application log file on a solaris 10 system. The requestName is the actual method name which gets called e.g it could be 'getAccount' or getId or getAddress etc etc ... (1 Reply)
Discussion started by: cesarNZ
1 Replies

8. Shell Programming and Scripting

Replicating jobs, renaming outout

Can anyone tell me if it's possible to write a script that will repeat the same job several times but give the output a slightly different name each time (i.e. change or add a number at the end of the output file)? Here is the script I use to run a single job: #!/bin/bash #PBS -N job0 #PBS -l... (1 Reply)
Discussion started by: peterjb100
1 Replies

9. Shell Programming and Scripting

Python indent - how do you do it?

A space, a tab? Just currious what, why, you indent in x way? Fwiw, I use vi, so kind'a currious how you vi folks approach indentation when writing code (eg python). Disclosure, I'm just learning python and have never seen a language use indentation so formally (I like it too:) ). I just... (7 Replies)
Discussion started by: sas
7 Replies

10. Shell Programming and Scripting

Sql command inside shell script runs without giving anything back as outout

#!/bin/sh # This script returns the number of rows updated from a function echo "The execution is starting ....." sqlplus -silent $UP <<EOF set serveroutput on set echo off set pagesize 0 VAR no_rows_updated NUMBER; EXEC :no_rows_updated :=0; DECLARE CURSOR c_update is SELECT * FROM... (4 Replies)
Discussion started by: LoneRanger
4 Replies
wcstools(1)						      General Commands Manual						       wcstools(1)

Name
       wcstools - Programs to access image world coordinate systems and catalogs

Setting an Image World Coordinate System
       imwcs  Automatically  find stars in a FITS or IRAF image, match them to HST Guide USNO A or USNO UJ Stars, compute the relation between sky
	      coordinates and image coordinates, and write in in the image header. [after U of Iowa SETWCS]

       delwcs Delete the WCS keywords from an image. If both EPOCH and EQUINOX are present, EQUINOX is also deleted.

Using an Image World Coordinate System
       imcat  List catalog sources which should be found in the area of the sky covered by a specific image.

       imsize Print center and size of image using WCS keywords in header

       imstar Find and list the n brightest stars in an IRAF or FITS image, with their sky coordinates if there is WCS information  in	the  image
	      header.

       sky2xy Print image pixel coordinates for given sky coordinates on the command line or in a list file.

       xy2sky Print sky coordinates for given image pixel coordinates on the command line or in a list file.

Catalog Utility Programs
       scat   Search the HST GSC, USNO-A2.0, or other catalog given a region on the sky.

       skycoor
	      Convert between J2000, B1950, and Galactic coordinates from the command line or a file.

Image Utility Programs
       addpix Add a constant value(s) to specified pixel(s)

       edhead Edit the header of a FITS file or the user parameters of an IRAF image file using a the text editor specified by the EDITOR environ-
	      ment variable.

       gethead
	      Return values for keyword(s) specified after filename.

       getpix Return value(s) of specified pixel(s)

       i2f    Read two-dimensional IRAF image file and write FITS image file

       imhead Print FITS or IRAF header

       imrot  Rotate and/or reflect FITS or IRAF image files

       setpix Set specified pixel(s) to specified value(s)

       sethead
	      Set header parameters in FITS or IRAF images.

       subpix Subtract a constant value(s) from specified pixel(s)

Author
       Doug Mink, SAO (dmink@cfa.harvard.edu)

6 July 2001							     WCSTools							       wcstools(1)
All times are GMT -4. The time now is 11:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy