Sponsored Content
Full Discussion: [awk] Math & Bold-Font?
Top Forums Shell Programming and Scripting [awk] Math & Bold-Font? Post 302935049 by sea on Thursday 12th of February 2015 01:07:35 PM
Old 02-12-2015
To get this right:
Split takes column 2, splits the string at the x's and saves its output in an array(like) variable for later usage.
Sadly, pixels get calculated to 0 Smilie but the bold text is working, thank you. Smilie

I'm now stuck at further parsing of bitrates, i'd like to put a 'kb' at its end as long bitrates do not exceed 1mb, then 'mb' should be appended.
Code:
	$AWK '/^#/ { next } ;
	{ 
		bitrate=$3+$4;
		switch (length(bitrates)) {
			case >=4:
				ext=mb
			default:
				ext=kb
		}
		
		split($2, A, "x");
		pixels=A[0] * A[1];
		print "\t* "BOLD$1RESET"\t"$2"\t"pixels"\t"$3"\t"$4"\t"bitrate""ext"\t"$5"\t"$6;
	}' BOLD="\033[1m" RESET="\033[0m" UNDERLINE="\033[4m" "$PRESETS"

But this doesnt show any output at all Smilie

Thank you in advance

EDIT:
So with Scrutinizer's suggestion, and commented out the switch block,
Code:
$AWK '/^#/ { next } ;
	{ 
		bitrate=$3+$4;
		#switch (length(bitrates)) {
		#	case >=4:
		#		ext=mb
		#	default:
		#		ext=kb
		#}
		
		split($2, A, "x");
		pixels=A[0] * A[1];
		print "\t* "BOLD$1RESET,$2 "   ",pixels,$3,$4,bitrate ext,$5,$6;
	}' BOLD="\033[1m" RESET="\033[0m" UNDERLINE="\033[4m" OFS="\t" "$PRESETS"

i get this:
Code:
	  Label	Resolution 	Pixels	Vidbit	Audbit	Bitrate	1min	Comment
	* scrn	resolve   	0	1024	192	1216	?	This
	* qvga	320x240   	0	240	128	368	2.8mb	Quarter
	* hvga	480x320   	0	320	128	448	3.3mb	Half
	* nhd	640x360   	0	512	192	704	5.2mb	Ninth
	* vga	640x480   	0	640	192	832	6.1mb	VGA
	* a-vga	640x480   	0	512	192	704	5.2mb	VGA,
	* wvga	768x480   	0	768	192	960	7.6mb	Wide
	* dvd	720x480   	0	720	256	976	7.2mb	DVD
	* wdvd	720x576   	0	800	256	1056	7.7mb	DVD-wide
	* fwvga	854x480   	0	768	256	1024	7.5mb	DVD-wide
	* hd	1280x720   	0	1024	384	1408	10.1mb	HD
	* a-hd	1280x720   	0	768	256	1024	8.5mb	HD,
	* fhd	1920x1080   	0	1792	384	2176	16.7mb	Full
	* a-fhd	1920x1080   	0	1280	256	1536	12.4mb	Full
	* qhd	2560x1440   	0	3072	448	3520	26.9mb	Quad
	* uhd	3840x2160   	0	5120	512	5632	43.4mb	4K,

Regarding the comments, do i need to have to blindly append columns after $6, so all the words of any possible comments become shown?

Thank you

Last edited by sea; 02-12-2015 at 02:16 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

awk logic and math help

Hi, My file has 2 fields and millions of lines. variableStep chrom=Uextra span=25 201 0.5952 226 0.330693 251 0.121004 276 0.0736858 301 0.0646982 326 0.0736858 401 0.2952 426 0.230693 451 0.221004 476 0.2736858 Each field either has a... (6 Replies)
Discussion started by: wyarosh
6 Replies

2. UNIX for Dummies Questions & Answers

colored/highlighted/bold matching pattern with awk ???

Hi ! Just wondering, is it possible to color or highlight or underline a matching pattern with awk ? Or write it in bold, italic.....? (3 Replies)
Discussion started by: lucasvs
3 Replies

3. Shell Programming and Scripting

Need help with AWK math

I am trying to do some math, so that I can compare the average of six numbers to a variable. Here is what it looks like (note that when I divide really big numbers, it isn't a real number): $ tail -n 6 named.stats | awk -F\, '{print$1}' 1141804 1140566 1139429 1134210 1084682 895045... (3 Replies)
Discussion started by: brianjb
3 Replies

4. Shell Programming and Scripting

output text in bold font using SED

hi I want to write a script, while using the SED editor, to output the text, in this case a variable, to the result file but highlighted it in bold, is it possible to do that? can you tell me how? eg. in text.txt sed '$ a\ '$variable' ' <text.txt >text2.txt so it will add the... (2 Replies)
Discussion started by: piynik
2 Replies

5. Shell Programming and Scripting

awk math and csv output

Hi I have this list 592;1;Z:\WB\DOCS;/FS3_100G/FILER112/BU/MPS/DOCS;;;;\\FILER112\BUMPS-DOCS\;580,116,544,878 Bytes;656,561 ;77,560 592;2;Z:\WB\FOCUS;/FS3_100G/FILER112/BU/MPS/FOCUS;;;;\\FILER112\BUMPS-FOCUS\;172,430 Bytes;6 ;0 ... (12 Replies)
Discussion started by: nakaedu
12 Replies

6. Shell Programming and Scripting

awk in horizontal and vertical math

Based on input ail,UTT,id1_0,COMBO,21,24,21,19,85 al,UTHAST,id1_0,COMBO,342,390,361,361,1454 and awk code as awk -F, '{ K=0; for(i=NF; i>=(NF-4); i--) { K=K+$i; J=J+$i;} { print K } } END { for ( l in J ) printf("%s ",J); }' I'm trying to add columns and lines in single line. line... (6 Replies)
Discussion started by: busyboy
6 Replies

7. Shell Programming and Scripting

awk --> math-operation in a array

Hi main object is categorize the difference of data-values (TLUFT02B - TLUFT12B). herefor i read out data-files which are named acording to the timeformat yyyymmddhhmm. WR030B 266.48 Grad 0 WR050B 271.46 Grad 0 WR120B 268.11 Grad 0 WV030B 2.51 m/s ... (6 Replies)
Discussion started by: IMPe
6 Replies

8. Shell Programming and Scripting

Count math using awk

Hi expert, I have log : TOTAL-TIME : 2125264636 DATA-BYTES-DOWN : 3766111307032 DATA-BYTES-UP : 455032157567 DL = (3766111307032/2125264636)/1024 = 1.73 UL = (455032157567/2125264636)/1024 = 0.21 I want the result : TOTAL = 1.94 ... (4 Replies)
Discussion started by: justbow
4 Replies

9. Shell Programming and Scripting

Math count %memory using awk

Hi expert, i have log this: Memory: 74410384 Memory: 75831176 Memory: 77961232 Memory: 77074656 Memory: 76086160 Memory: 77128592 Memory: 78045384 Memory: 76696040 Memory: 72401176 Memory: 72520016 Memory: 72137016 Memory: 73175832 Memory: 73034528 Memory: 71770736 Memory:... (4 Replies)
Discussion started by: justbow
4 Replies

10. What is on Your Mind?

Slowly Removing Bold Font Style - Step-by-Step

FYI, I'm slowly removing a lot of the bold font-styles from titles of discussions, forum titles, etc I'm not removing bold for the entire site because we do need bold from time to time, especially in posts and sometimes in other places. However, the original forum style had way too much... (3 Replies)
Discussion started by: Neo
3 Replies
VGA(4)							   BSD Kernel Interfaces Manual 						    VGA(4)

NAME
vga -- VGA graphics driver for wscons SYNOPSIS
options VGA_CONSOLE_SCREENTYPE="??x??" options VGA_CONSOLE_ATI_BROKEN_FONTSEL vga0 at isa? vga* at pci? wsdisplay* at vga? console ? DESCRIPTION
This driver handles VGA graphics hardware within the wscons(4) console framework. It doesn't provide direct device driver entry points but makes its functions available via the internal wsdisplay(4) interface. The vga driver supports text-mode hardware acceleration on the VGA hardware. Currently, the driver runs the display with a 720x400 pixel resolution. The VGA text-mode accelerator divides the display into fixed-size character cells. The size of the character cells specifies the number of characters available on the screen and the resolution of the font. The wsdisplay screen ``types'' supported by the vga driver are described by the number of character cells available on the screen. See below for a complete list of supported screen modes in the vga driver. Each screen mode requires a suitable font to be loaded into the kernel by the wsfontload(8) utility, before the screen can be used. The size of the font and the screen mode must match for use on the 720x400 display. For example, a screen mode with 80 columns and 40 rows requires a font where each character is 8 pixels wide and 10 pixels high. The vga driver can display fonts of the original IBM type and ISO-8859-1 encoded fonts. A builtin font of 256 characters and 8x16 pixels is always present on the VGA hardware. The colour VGA hardware supports the display of 16 different colours at the same time. It is possible with VGA colour systems to use fonts with 512 characters at any one time. This is due to the fact that with VGA adapters one can specify an alternate font to be used instead of bright letters (used for highlighting on the screen). As an experimental feature, the ``higher half'' fonts of the former NetBSD/i386 pcvt driver distribution can be used too if the kernel option ``WSCONS_SUPPORT_PCVTFONTS'' was set at compile time. This is only useful with the ``*bf'' screen types; a font containing the ASCII range of characters must be available too on this screen. Currently, the following screen types are supported: 80x25 This is the standard VGA text mode with 80 columns and 25 rows. Sixteen different colors can be displayed at the same time. Charac- ters are 8x16 pixels, and a font consists of 256 characters. 80x25bf is a modified version of the previous. It only allows 8 colors to be displayed. In exchange, it can access two fonts at the same time, so that 512 different characters can be displayed. 80x40 A text mode with 80 columns and 40 rows. Similar to the standard mode, 16 colors and 256 characters are available. Characters are 8x10 pixels. For this mode to be useful, a font of that character size must be downloaded. 80x40bf is analogously to ``80x25bf'' a version with 512 displayable characters but 8 colors only. 80x50 A text mode with 80 columns and 50 rows. Similar to the standard mode, 16 colors and 256 characters are available. Characters are 8x8 pixels. For this mode to be useful, a font of that character size must be downloaded. 80x50bf is analogously to ``80x25bf'' a version with 512 displayable characters but 8 colors only. 80x24 is a variant of the ``80x25'' screen type which displays 24 lines only. It uses the standard 8x16 VGA font. This mode might be use- ful for applications which depend on closer DEC VT100 compatibility. 80x24bf Analogously, like ``80x24'' but with 512 character slots and 8 colors. If you have an Ati videocard and you are experiencing problems with fonts other than 80x25, you can try to set options VGA_CONSOLE_ATI_BROKEN_FONTSEL in you kernel configuration and see if it helps. The vga driver supports multiple virtual screens on one physical display. The screens allocated on one display can be of different ``types''. The type is determined at the time the virtual screen is created and can't be changed later. Screens are either created at ker- nel startup (then the default type is used) or later with help of the wsconscfg(8) utility. SEE ALSO
isa(4), pcdisplay(4), pci(4), wscons(4), wsconscfg(8), wsfontload(8) BUGS
Only a subset of the possible text modes is supported. VGA cards are supposed to emulate an MDA if a monochrome display is connected. In this case, the device will naturally not support colors at all, but offer the capability to display underlined characters instead. The ``80x25bf'', ``80x40bf'', ``80x50bf'' and ``80x24bf'' screen types will not be available. This mode of operation has not been tested. BSD
May 4, 2003 BSD
All times are GMT -4. The time now is 07:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy