Sponsored Content
Full Discussion: Weird Interpretation by Awk
Top Forums Shell Programming and Scripting Weird Interpretation by Awk Post 302247013 by Annihilannic on Tuesday 14th of October 2008 07:13:39 PM
Old 10-14-2008
As the earlier posters intimated, the varying number of fields means you can't rely on field numbers... but since the output is neatly formatted and the fields are at constant character offsets you can use them instead:

Code:
awk '
        {
                tempnetwork=substr($0,4,15)
                if (tempnetwork !~ /^ *$/) network=tempnetwork
                nums=substr($0,61)
                print network,nums
        }
' inputfile > outputfile

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

SAR -b interpretation

I have used SAR -b to get some Unix cache / buffer metrics and the results are confusing me a bit. The pread/s & pwrit/s are showing 0. However the lread/s and lwrit/s are showing figures. I note also that the bread/s and bwrit/s are showing figures. I believe that pread/s and pwrit/s is not... (3 Replies)
Discussion started by: jimthompson
3 Replies

2. AIX

interpretation of sar

hello with a sar i have this result: System configuration: lcpu=48 ent=4.00 14:06:37 %usr %sys %wio %idle physc %entc 14:06:39 26 9 3 62 1.63 40.7 14:06:41 26 9 3 63 1.58 39.4 14:06:43 ... (0 Replies)
Discussion started by: pascalbout
0 Replies

3. UNIX for Advanced & Expert Users

Weird scenario with Awk

Guys, this one is rather odd. I've got an array of numbers, and I'm trying to select only the records with the string "Random" in the 4th column. I'm using awk in this format: awk '{ if (( $6 -eq Random )) print $0 }' For some odd reason, this is simply giving me the list of all the entries... (4 Replies)
Discussion started by: Khoomfire
4 Replies

4. UNIX for Advanced & Expert Users

Weird Awk issue

Hi All, a bit of a weird one here. I'm trying to pass a variable into an awk command, and I keep getting an error. I have the line nawk -F"," -v red=$random_variable '{print $red}' $w_dir/$file_name > $w_dir/${column_name} that keeps failing with the error nawk: can't open file {print... (17 Replies)
Discussion started by: Khoomfire
17 Replies

5. Shell Programming and Scripting

awk, sed, grep...weird style

my desired output is like this: so the thing is, I only need to show every of this part out but the frequency of that data is not fixed, so sometimes it may have 4 lines, or 6 lines or whatever in that file. However, the last line will always have empty space/line below it. (13 Replies)
Discussion started by: finalight
13 Replies

6. Shell Programming and Scripting

awk print behavior weird

Hi Experts I am facing a weird issue while using print statement in awk. I have a text file with 3 fields shown below: # cat f1 234,abc,1000 235,efg,2000 236,jih,3000 # When I print the third column alone, I dont face any issue as shown below: # awk '{print $3 }' FS=, f1 1000 2000... (5 Replies)
Discussion started by: guruprasadpr
5 Replies

7. Shell Programming and Scripting

awk weird problem.

awk 'BEGIN{print 1.2.3.4}' 1.20.30.4 Can anyone explain why has extra "0" in the IP address? (3 Replies)
Discussion started by: newoz
3 Replies

8. Shell Programming and Scripting

Interpretation of awk code in linux

HI I have a following code: CM_PROJHOME_DIR=`echo ${SCRNAME} | awk '{FS="/"; p=NF-5; for (i=1; i<= p ; i++) t=t$i"/"; print t}'` where SCRNAME=`whence $0 | sed -e 's/\.\///g'` I need to modify the code to work in linux and also the interpretation like what is the code exactly doing.... (4 Replies)
Discussion started by: vee_789
4 Replies

9. Shell Programming and Scripting

Weird awk problem

Hi, I have a simple awk script: BEGIN{} { $a=$2-$1; print $a } END{if(NR==0){ print "0" } } to which I provide the following input 2.9 14 22.2 27 (4 Replies)
Discussion started by: jamie_123
4 Replies

10. Shell Programming and Scripting

awk weird error

Here is the awk code i wrote : if ; then gawk -v field_position="$field_position" -v field_length="$field_length" -v header="$header" -v trailer="$trailer" -v lr="$lr" '{ if(NR==1&&header=="1") { next } if(NR==lr&&trailer=="1") { next }... (1 Reply)
Discussion started by: ysvsr1
1 Replies
AMC-IMPRIME(1)						       Auto Multiple Choice						    AMC-IMPRIME(1)

NAME
AMC-imprime - prints AMC multiple choice answer sheets to be distributed to the students SYNOPSIS
auto-multiple-choice imprime --sujet subject.pdf --fich-nums numbers-file.txt --data data-dir --methode method [where-to-print-arguments...] DESCRIPTION
The AMC-imprime.pl command prints selected copies from a AMC multiple choice answer sheet. What to print The following arguments describe what to print: --sujet subject.pdf sets the subject file (prepared by AMC-prepare(1)). --fich-nums numbers-file.txt gives a file where the numbers of the copies to be printed are written (one number per line). If this argument is not given, all the copies will be printed. --data data-dir gives the directory where data files are (see for example AMC-meptex(1)). The layout database in the data directory is used to know at which page of the subject file each copy begins and ends. Where to print Several printing methods are currently defined: o with "--methode CUPS", AMC-imprime.pl prints to a CUPS printer. One print job is sent for each copy, allowing for exemple to use stapling. Use the following options with this method: --imprimante printer sets the CUPS printer name to print to. --options cups-options gives CUPS options, in the opt1=value1,opt2=value2,... format. o with "--methode file", AMC-imprime.pl outputs the answer sheets to files (one for each copy). --output filename sets the filename for outputs. The '%e' sequence will be replaced by a 4-digits copy number. If filename does not contain '%e', the string '-%e.pdf' will be added at its end. o with "--methode command", AMC-imprime.pl will use a provided command for each copy. --print-command command gives the command to be used for printing. The command string will be split at each space character (even when using quotes...). The sequence '%f' will be replaced by a PDF filename (containing the copy to print), and '%e' will be replaced by the copy number. AUTHORS
Alexis Bienvenue <paamc@passoire.fr> Main author Jean Berard Translation from French Georges Khaznadar Translation from French COPYRIGHT
Copyright (C) 2008-2012 Alexis Bienvenue This document can be used according to the terms of the GNU General Public License, version 2 or later. Auto Multiple Choice 1.1.1 06/19/2012 AMC-IMPRIME(1)
All times are GMT -4. The time now is 08:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy