"Sort and vectors on awk"

Post #302771645 by xshock on Thursday 21st of February 2013 06:49:21 AM

Full Discussion: Sort and vectors on awk
nawk - how to print variable value to a file?


I have a shell script which uses an awk program inside. There is a variable $count inside an "if" loop which counts the no of iterations.

Now, how to print that $count value to file (or) how to export that value to a variable outside awk program. i.e, awk to shell ?

Please help.
Test Your Knowledge in Computers #106
Difficulty: Easy
A kernel is at the heart of the Linux OS; and this kernel acts as an interface between the user and underlying hardware.
True or False?

9 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

awk sort help

1. The problem statement, all variables and given/known data: I dont know what I do wrong, I am trying to create shell programming database: I have this command first: && > $fname ... echo $Name:$Surname:$Agency:$Tel:$Ref: >> $fname then I have echo " Name Surname Agency Tel... (2 Replies)
Discussion started by: jeht
2 Replies

2. Shell Programming and Scripting

Sort in AWK

Hi, I usually use Access to sort data however for some reason its not working. Our systems guys and myself cannot figure it out so ive tried to use AWK to do the sorting. The file is made up of single lines in the format ... (4 Replies)
Discussion started by: eknryan
4 Replies

3. Shell Programming and Scripting

Using Awk to efficiently substitute values using 3 vectors

I'm trying to efficiently combine the fields of two vectors (vectors b and c) into a new vector (vector d) as defined by instructions from a 3rd vector (vector a). So vector a has either a 1 or 2 in each field specifying which vector (b or c respectively) should go into that field. Vector a is... (4 Replies)
Discussion started by: LaTortuga
4 Replies

4. Shell Programming and Scripting

Sort with Awk, sed ....

I want to print out the lines that have the max value in column 3. and count the occurrence of column 1; if there are more than one occurrences, line with highest column 2 value will be printed. I have this data: input: AV 234 25 AV 256 76 AS 421 34 AV 124 76 BD 136 71 BD 241 76 AW... (10 Replies)
Discussion started by: aydj
10 Replies

5. Shell Programming and Scripting

Awk sort and unique

Input file --------- 12:name1:|host1|host1|host2|host1 13:name2:|host1|host1|host2|host3 14:name3: ...... Required output --------------- 12:name1:host1(2)|host1(1) 13:name2:host1(2)|host2(1)|host3(1) 14:name3: where (x) - Count how many times field appears in last column ... (3 Replies)
Discussion started by: greycells
3 Replies

6. Shell Programming and Scripting

awk sort

input file abc1 abc23 abc12 abc15 output abc1 abc12 abc15 abc23 (9 Replies)
Discussion started by: yanglei_fage
9 Replies

7. Shell Programming and Scripting

how to sort inside awk

Hi guys I have a problem trying to sort output produced with the help of 'Awk'. After "grepping" the pattern out of the file and sorting it, sort command acts a little strange: $ grep -w -n -i "p*cmo" /bb/data/rmt4db.lrl | sort -r 32:P1096CMO 63836 344 passthru 31:P1084CMO 121335 329 passthru... (3 Replies)
Discussion started by: aoussenko
3 Replies

8. Shell Programming and Scripting

Need help on horizontal sort with AWK

dear friends.. i have data : 20130603;ABCD;ABCD1;14030;51271;0.000;0.000;21.000 20130603;ABCD;ABCD2;14030;51272;4853.000;53591.000;40539.000 20130603;ABCD;ABCD3;14030;51273;38024.000;385068.000;396424.000 20130603;ABCD;EFGH1;14030;51334;285879.000;563964.000;141780.000... (4 Replies)
Discussion started by: buncit8
4 Replies

9. Shell Programming and Scripting

Sort String using awk

Hi, I need help to sort string using awk. I don't want to use sed or perl as I want to add this functionality in my existing awk script Basically I have a variable in AWK which is string with comma separated value. I want to sort that string before using that variable in further processing for... (10 Replies)
Discussion started by: rocky.community
10 Replies
Sort::Key::Types(3pm)					User Contributed Perl Documentation				     Sort::Key::Types(3pm)

Sort::Key::Types - handle Sort::Key data types SYNOPSIS
use Sort::Key::Types qw(register_type); register_type(Color => sub { $_->R, $_->G, $_->B }, qw(int, int, int)); # you better # use Sort::Key::Register ... DESCRIPTION
The Sort::Key family of modules can be extended to support new key types using this module (or the more friendly Sort::Key::Register). FUNCTIONS The following functions are provided: Sort::Key::register_type($name, &gensubkeys, @subkeystypes) registers a new datatype named $name defining how to convert it to a multikey. &gensubkeys should convert the object of type $name passed on $_ to a list of values composing the multikey. @subkeystypes is the list of types for the generated multikeys. For instance: Sort::Key::Types::register_type 'Person', sub { $_->surname, $_->name, $_->middlename }, qw(str str str); Sort::Key::Types::register_type 'Color', sub { $_->R, $_->G, $_->B }, qw(int int int); Once a datatype has been registered it can be used in the same way as types supported natively, even for defining new types, i.e.: Sort::Key::Types::register_type 'Family', sub { $_->father, $_->mother }, qw(Person Person); SEE ALSO
Sort::Key, Sort::Key::Merger, Sort::Key::Register. COPYRIGHT AND LICENSE
Copyright (C) 2005-2007 by Salvador Fandin~o, <sfandino@yahoo.com>. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available. perl v5.14.2 2012-06-30 Sort::Key::Types(3pm)

Featured Tech Videos

All times are GMT -4. The time now is 08:55 PM.
Unix & Linux Forums Content Copyright 1993-2019. All Rights Reserved.
Privacy Policy