Sponsored Content
Full Discussion: Weird Interpretation by Awk
Top Forums Shell Programming and Scripting Weird Interpretation by Awk Post 302247015 by treesloth on Tuesday 14th of October 2008 07:20:12 PM
Old 10-14-2008
The character offset idea is excellent. You might also find the idea of "x from last" useful-- that is, instead of printing fields 5, 6 and 7, you can print the third from last, second from last, and last fields. The structure for this is:

Code:
 awk '{print $(NF-2) " " $(NF-1) " " $NF}'

Best of luck.
 

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
thailpof(8)						      System Manager's Manual						       thailpof(8)

NAME
thailpof - Generic filter for printing Thai text files SYNOPSIS
/usr/lbin/thailpof [-c] [-h host] [-H] [-i indent] [-l length] [-n login] [-P printer_id] [-S] [-w width] [accounting_file] OPTIONS
Prints control characters. Specifies the host name of the job owner. This name can contain Thai characters. Enables half-height printing mode. In printers without a one-pass printing mode, Thai characters are printed on 3 levels, or 3 lines. When half-height printing mode is enabled, the 3 levels are printed in 1.5 lines, which improves the appearance of output. The cost of this improvement is slower print- ing speed. Specifies the amount of indentation. The default value is no (no indentation). Specifies the page length in lines. The default value is 22. Specifies the login name of the job owner. This name can contain Thai characters. Specifies the printer ID in the format that conforms to the Wototo Specification. This format is [bb][mm][nn] where: Is the brand ID, representing the brand of the printer. Is the model ID, representing the model of the printer. Is the code ID, specifying the character code used by the printer. Enables space- compensation mode. Many of the existing tools for text alignment cannot handle nonspacing characters properly. When printing output from such tools, enabling space-compensation mode improves alignment of output text. Specifies the page width in columns. The default value is 80. OPERANDS
Specifies the file to record accounting information. DESCRIPTION
The thailpof filter is a generic print filter for Thai text files. The filter handles the device dependencies of printers and performs accounting functions. At print job completion times, accounting records are written to the file specified by the af field in /etc/print- cap. The filter can handle plain text files and files that have been preprocessed by nroff. Either kind of file can contain Thai characters. The thailpof filter translates nroff control sequences for underlining, superscripting, and subscripting into the proper control sequences for the printer. The thailpof filter can be the specified filter in both the of and the if fields in the /etc/printcap file. For a description of these fields, see printcap(4). To print Thai characters on the flag page using 3-pass mode, you must specify /usr/lbin/thailpof in the of field of the /etc/printcap file. In 3-pass mode, however, the flag page is not printed on one page. Therefore, if you do not plan to print Thai characters on the flag page, or if you are using one-pass mode, do not specify /usr/lbin/thailpof in the of field. NOTES
The lpr command supports a number of options and associated arguments to enable localization features supported by various printers. The following can be used with the thailpof filter: To specify one-and-a-half line printing To enable space-compensation mode. To specify the pathname of the character code table For a complete description of this option and its associated arguments or values, refer to lpr(1). ERRORS
The lf field (default value is /dev/null) in the /etc/printcap file specifies the name of the error log. SEE ALSO
Commands: lpr(1), pr(1), lpd(8), pac(8) Files: printcap(4) Others: i18n_printing(5) thailpof(8)
All times are GMT -4. The time now is 10:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy