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
Widgets::ListBox::MultiColumn(3pm)			User Contributed Perl Documentation			Widgets::ListBox::MultiColumn(3pm)

NAME
Curses::Widgets::ListBox::MultiColumn - Multi-Column List Box Widgets MODULE VERSION
$Id: MultiColumn.pm,v 0.1 2002/11/14 01:28:49 corliss Exp corliss $ SYNOPSIS
use Curses::Widgets::ListBox::MultiColumn; $lb = Curses::Widgets::ListBox::MultiColumn->new({ COLUMNS => [0, 5, 10, 3, 3], LISTITEMS => [@list], }); $lb->draw($mwh, 1); See the Curses::Widgets pod for other methods. REQUIREMENTS
Curses Curses::Widgets Curses::Widgets::ListBox DESCRIPTION
Curses::Widgets::ListBox::MultiColumn is an extension of the standard Curses::Widgets::ListBox that allows a list of columns, with each column a specified width. METHODS
new (inherited from Curses::Widgets) $tm = Curses::Widgets::ListBox->new({ COLUMNS => [0, 5, 10, 3, 3], LISTITEMS => [@list], HEADERS => [@headers], HEADERCOLFG => 'white', HEADERCOLBG => 'green', BIGHEADER => 1, }); All of the same key values apply here as they do for the parent class Curses::Widgets::ListBox. In addition, the following new keys are defined: Key Default Description ============================================================ COLUMNS [] Column widths LISTITEMS [] List of list values HEADERS [] Column header labels HEADERFGCOL undef Header foreground colour HEADERBGCOL undef Header background colour BIGHEADER 0 Use more graphics for the header KEYINDX 0 Index of key column If headers are defined but one or both of the header colours are not, then they will default to the widget fore and background. NOTE: Headers take up more lines in addition to the border (one line for the normal, small header, two lines for the larger). You need to take that into account when setting the geometry. If no labels are passed in the HEADERS array, no space will be used for the headers. The KEYINDX value is currently only used to match keystrokes against for quick navigation. draw $lb->draw($mwh, 1); The draw method renders the list box in its current state. This requires a valid handle to a curses window in which it will render itself. The optional second argument, if true, will cause the field's text cursor to be rendered as well. HISTORY
1999/12/29 -- Original list box widget in functional model 2001/07/05 -- First incarnation in OO architecture AUTHOR
/COPYRIGHT (c) 2001 Arthur Corliss (corliss@digitalmages.com) perl v5.8.8 2006-09-14 Widgets::ListBox::MultiColumn(3pm)
All times are GMT -4. The time now is 10:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy