10-18-2007
Instead of a print, use a printf command. It allows you to specifiy a mask, then the data to print. for example
printf("%-30s", "MY NAME");
will right justify the value in the column. If you are a C programmer, it follows that printing convention. I suggest looking up the online (free and in pdf) version of "Effective awk programming" by Arnold Robbins for more information.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a set of files of multi-line records with the records separated by a blank line. I needed to add a record number to the front of each line followed by a colon and did the following:
awk 'BEGIN {FS = "\n"; RS = ""}{for (i=1; i<=NF; i++)print NR,":",$i}' ~/Desktop/data98-1-25.txt >... (3 Replies)
Discussion started by: RacerX
3 Replies
2. Shell Programming and Scripting
Hi Sorry to multipost. I am opening the new thread because the earlier threads head was misleading to my current doubt.
and i am stuck.
list=`cat /u/Test/programs`;
psg "ServTest" | awk -v listawk=$list '{
cmd_name=($5 ~ /^/)? $9:$8
for(pgmname in listawk)
... (6 Replies)
Discussion started by: Anteus
6 Replies
3. Infrastructure Monitoring
I have a file has following records
policy glb id 1233 name Permit ping from "One" to "Second" "Address1" "Any" "ICMP-ANY" permit
policy id 999251
service "snmp-udp"
exit
policy glb id 1234 name Permit telnet from "One" to "Second" "Address2" "Any" "TCP-ANY" permit
policy id 1234... (3 Replies)
Discussion started by: baskar
3 Replies
4. Shell Programming and Scripting
Some records in a file look like this, with any number of lines between start and end flags:
/Start
Some stuff
Banana 1
Some more stuff
End/
/Start
Some stuff
End/
/Start
Some stuff
Some more stuff
Banana 2
End/
...how would I process this file to find records containing the... (8 Replies)
Discussion started by: cs03dmj
8 Replies
5. UNIX for Dummies Questions & Answers
Hi all,
I So, I've got a monster text document comprising a list of various company names and associated info just in a long list one after another. I need to sort them alphabetically by name...
The text document looks like this:
Company Name:
the_first_company's_name_here
Address:... (2 Replies)
Discussion started by: quee1763
2 Replies
6. Shell Programming and Scripting
Now that I've parsed out the data that I desire I'm left with variable length multi-line records that are field seperated by new lines (\n) and record seperated by a single empty line ("")
At first I was considering doing something like this to append all of the record rows into a single row:
... (4 Replies)
Discussion started by: daveyabe
4 Replies
7. Shell Programming and Scripting
I have a file with data records separated by multiple equals signs, as below.
==========
RECORD 1
==========
RECORD 2
DATA LINE
==========
RECORD 3
==========
RECORD 4
DATA LINE
==========
RECORD 5
DATA LINE
==========
I need to filter out all data from this file where the... (2 Replies)
Discussion started by: Finja
2 Replies
8. Shell Programming and Scripting
Hey, not too good at this, so I only managed a clumsy and SLOW solution to my problem that needs a drastic speed up. Any ideas how I write the following in awk only?
Code is supposed to do...
For every line read column values $6, $7, $8 and do a calculation with the same column values of every... (6 Replies)
Discussion started by: origamisven
6 Replies
9. Shell Programming and Scripting
Greetings Experts,
As part of automating the sql generation, I have the source table name, target table name, join condition stored in a file join_conditions.txt which is a delimited file (I can edit the file if for any reason). The reason I needed to store is I have built SELECT list without... (5 Replies)
Discussion started by: chill3chee
5 Replies
10. Shell Programming and Scripting
Input File:
>Seq1
ASDADAFASFASFADGSDGFSDFSDFSDFSDFSDFSDFSDFSDFSDFSDFSD
>Seq2
SDASDAQEQWEQeqAdfaasd
>Seq3
ASDSALGHIUDFJANCAGPATHLACJHPAUTYNJKG
......
Desired Output File
>Seq1
ASDADAFASF
ASFADGSDGF
SDFSDFSDFS
DFSDFSDFSD
FSDFSDFSDF
SD
>Seq2 (4 Replies)
Discussion started by: patrick87
4 Replies
LEARN ABOUT MINIX
sortbib
sortbib(1) User Commands sortbib(1)
NAME
sortbib - sort a bibliographic database
SYNOPSIS
sortbib [-s KEYS] database...
DESCRIPTION
sortbib sorts files of records containing refer key-letters by user-specified keys. Records may be separated by blank lines, or by `.[' and
`.]' delimiters, but the two styles may not be mixed together. This program reads through each database and pulls out key fields, which are
sorted separately. The sorted key fields contain the file pointer, byte offset, and length of corresponding records. These records are
delivered using disk seeks and reads, so sortbib may not be used in a pipeline to read standard input.
The most common key-letters and their meanings are given below.
%A Author's name
%B Book containing article referenced
%C City (place of publication)
%D Date of publication
%E Editor of book containing article referenced
%F Footnote number or label (supplied by refer)
%G Government order number
%H Header commentary, printed before reference
%I Issuer (publisher)
%J Journal containing article
%K Keywords to use in locating reference
%L Label field used by -k option of refer
%M Bell Labs Memorandum (undefined)
%N Number within volume
%O Other commentary, printed at end of reference
%P Page number(s)
%Q Corporate or Foreign Author (unreversed)
%R Report, paper, or thesis (unpublished)
%S Series title
%T Title of article or book
%V Volume number
%X Abstract -- used by roffbib, not by refer
%Y,Z Ignored by refer
By default, sortbib alphabetizes by the first %A and the %D fields, which contain the senior author and date.
sortbib sorts on the last word on the %A line, which is assumed to be the author's last name. A word in the final position, such as `jr.'
or `ed.', will be ignored if the name beforehand ends with a comma. Authors with two-word last names or unusual constructions can be sorted
correctly by using the nroff convention ` ' in place of a blank. A %Q field is considered to be the same as %A, except sorting begins with
the first, not the last, word. sortbib sorts on the last word of the %D line, usually the year. It also ignores leading articles (like `A'
or `The') when sorting by titles in the %T or %J fields; it will ignore articles of any modern European language. If a sort-significant
field is absent from a record, sortbib places that record before other records containing that field.
No more than 16 databases may be sorted together at one time. Records longer than 4096 characters will be truncated.
OPTIONS
-sKEYS Specify new KEYS. For instance, -sATD will sort by author, title, and date, while -sA+D will sort by all authors, and date. Sort
keys past the fourth are not meaningful.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWdoc |
+-----------------------------+-----------------------------+
SEE ALSO
addbib(1), indxbib(1), lookbib(1), refer(1), roffbib(1), attributes(5)
BUGS
Records with missing author fields should probably be sorted by title.
SunOS 5.10 14 Sep 1992 sortbib(1)