Sponsored Content
Top Forums Shell Programming and Scripting Meaning of NF{ a[$1]=a[$1]" "$2 ; next }? Post 302389754 by Scott on Monday 25th of January 2010 06:25:06 PM
Old 01-25-2010
Hi.

It's part of an awk script.

NF{...} means if there are more than zero fields in the current record (i.e. not a blank line) perform the action between { and }

An awk script is made up of patterns (conditions, really) and actions

PATTERN { ACTION }

If PATTERN evaluates to true, then ACTION is performed.

[NF is an awk variable giving the number of fields in the current record. If it's non-zero, ACTION is performed.]

{ a[$1]=a[$1]" " $2; next } means append the value of field two ($2) to an array (a) indexed by the value of field one ($1).

The END section is performed after all input files are processed.

for(i in a) means assign to i, in turn, each element of a
and print the index value i, followed by the value referenced by that index (a[i]).

The two lines you posted say: add field two to an array called a, indexed by distinct values of field one.

HTH Smilie
 

9 More Discussions You Might Find Interesting

1. AIX

What's meaning of "POWER" in diag command.?

I ran 'diag' command to verify disk follow the below steps. DIAG------?task selection-------ssa service aid-----Link verification I found that there are 3 types of status. (Good, Failed and Power). scp2: pdisk23 D69E584F 0 16 Power scp2: pdisk19 D657E7A9 1 15 Power scp2: pdisk28... (1 Reply)
Discussion started by: pattarapongn
1 Replies

2. UNIX for Dummies Questions & Answers

Meaning of $var->{"@$row[0]"}=" "; ???

while (my $row = $sth->fetchrow_arrayref) { $var->{"@$row"}=" "; } Can anyone help me understanding above mentioned. i) As per my knowledge $row is taking ARRAY Refernce from the database ii) @$row is containing the value of 0th index of the array, testted the same. but I am not able... (0 Replies)
Discussion started by: jaigs_27
0 Replies

3. Shell Programming and Scripting

Meaning of "if [ -x /opt/OV/bin/ovpolicy ]"

Hi, Could someone pls help me on the below command: if then ------------------ ------------ fi if then ------------- ------------------- ------------------- fi What does this signify? Thanks, .. (4 Replies)
Discussion started by: ww26683
4 Replies

4. UNIX for Dummies Questions & Answers

the meaning of "!:*" in "alias foo 'command\!:*' filename"

Hi: How can I remove my own post? Thanks. (2 Replies)
Discussion started by: phil518
2 Replies

5. Shell Programming and Scripting

Meaning of "b" modifier in "sort" command

I need to sort the following file by the rhdiskpower devices in the last column: Total_MB Free_MB OS_MB Name Failgroup Library Label UDID Product Redund Path 1024 851 1024 OCRVOT1_0000 OCRVOT1_0000 System UNKNOWN ... (3 Replies)
Discussion started by: wjssj
3 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. UNIX for Dummies Questions & Answers

Variable "##*", "% *" meaning

Hi, What means "##*", "% *" in a variable?? I have this in the script that i'm reading: ... read line echo $line echo ${line#* } echo ${line##* } echo ${line% * } ... The first print: DN: RCROOT ONRM_ROOT_MO SNW ONRM_ROOT_MO BSC BSCCC2 BTS ALTOHATILLONOR The second print:... (2 Replies)
Discussion started by: darocham
2 Replies

8. UNIX for Dummies Questions & Answers

What is the meaning of "-s" option in "if" statement?

Hi Guys, I'm sorry but I can't find answer for this, what is the meaning of -s option in "if" statement on unix scipting. Please see sample below: opath=/home/output for i in N1 N2 N3 N4 do echo $i if then grep $i $opath/N5_CRAI > $opath/N5_$i.crai chmod 777 $opath/N5_$i.crai ... (7 Replies)
Discussion started by: rymnd_12345
7 Replies

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 03:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy