Sponsored Content
Top Forums Shell Programming and Scripting Putting values into order in a field using awk Post 302720971 by Homa on Thursday 25th of October 2012 03:51:12 AM
Old 10-25-2012
Thank you, although it doesn't sort the third column.

Using this command, how I can keep the spacing between my fields? I have used this command but it doesn' work properly.

Code:
#awk 'BEGIN{OFS=ORS=""}{$3/=1000000 print\n"}' infile


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK - printing certain fields when field order changes in data file

I'm hoping someone can help me on this. I have a data file that greatly simplified might look like this: sec;src;dst;proto 421;10.10.10.1;10.10.10.2;tcp 426;10.10.10.3;10.10.10.4;udp 442;10.10.10.5;10.10.10.6;tcp sec;src;fac;dst;proto 521;10.10.10.1;ab;10.10.10.2;tcp... (3 Replies)
Discussion started by: eric4
3 Replies

2. UNIX for Dummies Questions & Answers

Awk search for max and min field values

hi, i have an awk script and I managed to figure out how to search the max value but Im having difficulty in searching for the min field value. BEGIN {FS=","; max=0} NF == 7 {if (max < $6) max = $6;} END { print man, min} where $6 is the column of a field separated by a comma (3 Replies)
Discussion started by: Kirichiko
3 Replies

3. Shell Programming and Scripting

counting lines containing two column field values with awk

Hello everybody, I'm trying to count the number of consecutive lines in a text file which have two distinctive column field values. These lines may appear in several line blocks within the file, but I only want a single block to be counted. This was my first approach to tackle the problem (I'm... (6 Replies)
Discussion started by: origamisven
6 Replies

4. Shell Programming and Scripting

AWK: combining consecutive values in a field

Hi, Here is my sample input X 2 AAA Y 3 BBB Y 2 CCC Z 4 DDD In field 1, if the value of one line is same as that of next line, I want to concatenate the corresponding value of the second line in the third field with the value of the third field of first line. And I dont need the third... (2 Replies)
Discussion started by: polsum
2 Replies

5. Shell Programming and Scripting

SED/AWK to edit/add field values in a record

Hi Experts, I am new to shell scripting. Need some help in doing one task given by the customer. The sample record in a file is as follows: 3538,,,,,,ID,ID1,,,,,,,,,,, It needs to be the following: 3538,,353800,353800,,,ID,ID1,,,,,COLX,,,,,COLY, And i want to modify this record in... (3 Replies)
Discussion started by: sugarcane
3 Replies

6. Shell Programming and Scripting

awk help - matching a field with certail values

Hello there, I have a file with few fields separated by ":". I wrote a below awk to manipulate this file: awk 'BEGIN { FS=OFS=":" }\ NR != 1 && $2 !~ /^98/ && $8 !~ /^6/{print $0}' $in_file > $out_file What I wanted was that if $8 field contains any of the values - 6100, 6110, 6200 -... (2 Replies)
Discussion started by: juzz4fun
2 Replies

7. UNIX for Dummies Questions & Answers

Values with common field in same line with awk

Hi all ! I almost did it but got a small problem. input: cars red cars blue cars green truck black Wanted: cars red-blue-green truck black Attempt: gawk 'BEGIN{FS="\t"}{a = a (a?"-":"")$2; $2=a; print $1 FS $2}' input But I also got the intermediate records... (2 Replies)
Discussion started by: beca123456
2 Replies

8. UNIX for Dummies Questions & Answers

Generating all possible combinations of values in field 1 (awk)

Input: A|1 B|2 C|3 D|4 Output: A+B|3 A+C|4 A+D|5 B+C|5 B+D|6 C+D|7 A+B+C|6 A+B+D|7 A+C+D|8 B+C+D|9 A+B+C+D|10 I only managed to get the output for pairs of $1 values (i.e. combination of length 2): (4 Replies)
Discussion started by: beca123456
4 Replies

9. Shell Programming and Scripting

Insert field values in a record using awk command

Hi Friends, Below is my input file with "|" (pipe) as filed delimiter: My Input File: HDR|F1|F2||||F6|F7 I want to inser values in the record for field 4 and field 5. Expected output HDR|F1|F2||F4|F5|F6|F7 I am able to append the string to the end of the record, but not in between the... (3 Replies)
Discussion started by: Ajay Venkatesan
3 Replies

10. UNIX for Beginners Questions & Answers

awk GSUB read field values from multiple text files

My program run without error. The problem I am having. The program isn't outputting field values with the column headers to file.txt. Each of the column headers in file.txt has no data. MEMSIZE SECOND SASFoundation Filename The output results in file.txt should show: ... (1 Reply)
Discussion started by: dellanicholson
1 Replies
Alzabo::Create::Index(3pm)				User Contributed Perl Documentation				Alzabo::Create::Index(3pm)

NAME
Alzabo::Create::Index - Index objects for schema creation SYNOPSIS
use Alzabo::Create::Index; DESCRIPTION
This object represents an index on a table. Indexes consist of columns and optional prefixes for each column. The prefix specifies how many characters of the columns should be indexes (the first X chars). Some RDBMS's do not have a concept of index prefixes. Not all col- umn types are likely to allow prefixes though this depends on the RDBMS. The order of the columns is significant. INHERITS FROM
"Alzabo::Index" Note: all relevant documentation from the superclass has been merged into this document. METHODS
new The constructor takes the following parameters: * table => "Alzabo::Create::Table" object The table that this index is indexing. * columns => [ "Alzabo::Create::Column" object, .. ] * columns => [ { column => "Alzabo::Create::Column" object, prefix => $prefix }, repeat as needed ... ] This parameter indicates which columns that are being indexed. It can either be an array reference of column objects, or an array ref- erence of hash references, each with a key called column and one called prefix. The prefix key is optional. * unique => $boolean Indicates whether or not this is a unique index. * fulltext => $boolean Indicates whether or not this is a fulltext index. * function => $string This can be used to create a function index where supported. The value of this parameter should be the full function, with column names, such as "LCASE( username )". The "columns" parameter should include all the columns used in the function. Returns a new "Alzabo::Create::Index" object. Throws: "Alzabo::Exception::Params", "Alzabo::Exception::RDBMSRules" table Returns the "Alzabo::Create::Table" object to which the index belongs. columns Returns an ordered list of the "Alzabo::Create::Column" objects that are being indexed. add_column Adds a column to the index. This method takes the following parameters: * column => "Alzabo::Create::Column" object * prefix => $prefix (optional) Throws: "Alzabo::Exception::Params", "Alzabo::Exception::RDBMSRules" delete_column ("Alzabo::Create::Column" object) Deletes the given column from the index. Throws: "Alzabo::Exception::Params", "Alzabo::Exception::RDBMSRules" prefix ("Alzabo::Create::Column" object) A column prefix is, to the best of my knowledge, a MySQL specific concept, and as such cannot be set when using an RDBMSRules module for a different RDBMS. However, it is important enough for MySQL to have the functionality be present. It allows you to specify that the index should only look at a certain portion of a field (the first N characters). This prefix is required to index any sort of BLOB column in MySQL. This method returns the prefix for the column in the index. If there is no prefix for this column in the index, then it returns undef. set_prefix This method takes the following parameters: * column => "Alzabo::Create::Column" object * prefix => $prefix Throws: "Alzabo::Exception::Params", "Alzabo::Exception::RDBMSRules" unique Returns a boolean value indicating whether the index is a unique index. set_unique ($boolean) Sets whether or not the index is a unique index. fulltext Returns a boolean value indicating whether the index is a fulltext index. set_fulltext ($boolean) Set whether or not the index is a fulltext index. Throws: "Alzabo::Exception::Params", "Alzabo::Exception::RDBMSRules" register_column_name_change This method takes the following parameters: * column => "Alzabo::Create::Column" object The column (with the new name already set). * old_name => $old_name This method is called by the table object which owns the index when a column name changes. You should never need to call this yourself. Throws: "Alzabo::Exception::Params" id The id is generated from the table, column and prefix information for the index. This is useful as a canonical name for a hash key, for example. Returns a string that is the id which uniquely identifies the index in this schema. AUTHOR
Dave Rolsky, <autarch@urth.org> perl v5.8.8 2007-12-23 Alzabo::Create::Index(3pm)
All times are GMT -4. The time now is 06:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy