Sponsored Content
Full Discussion: [awk] Math & Bold-Font?
Top Forums Shell Programming and Scripting [awk] Math & Bold-Font? Post 302935068 by sea on Thursday 12th of February 2015 02:04:24 PM
Old 02-12-2015
Sadly, setting / comparing with value seems to be an issue for my approach:
Code:
	$AWK '/^#/ { next } ;
	{ 
		bitrate=$3+$4;
		len=( length(bitrates) ); print len
		len = length(bitrates)  ; print len
		ext="kb"; if(len >= 4) ext="mb"; 
		if(len >= 4) bitrates=(substr(bitrates,3));

		split($2, A, "x");
		pixels=A[0] * A[1];
		
		print "\t* "BOLD$1RESET,$2 "   ",pixels,$3,$4,bitrate ext,$5,$6" "$7" "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15;
		
	}' BOLD="\033[1m" RESET="\033[0m" UNDERLINE="\033[4m" OFS="\t" "$PRESETS"

  1. While i do see now 'kb' for all the bitrates, it neither changes to mb when bitrate is 5120, nor does it cut 3 numbers from the string.
  2. Is there a better way o display the whole comment, rather than " "$7" "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15 to preseve words?
  3. pixels are still empty, and would require the same 'handling' as the bitrates.

len is always 0, so that is why the check doesnt work, but how to fix that please?

Thank you
 

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
NcdT(1) 						      General Commands Manual							   NcdT(1)

NAME
ncdt - directory tree printer with extended capabilities SYNOPSIS
ncdt [-db?] [--dirs] [--bitrate] [--prefix text ] [--help] [ directory [ name ]] DESCRIPTION
ncdt is a small utility for printing directory trees. It has some additional features not found in tree(1). Additional capabilities are: - size field for directories displays the summary size of directory subtree instead of the size of the special file (which is somewhat more useful) - sizes are displayed in a more readable format (that's a minor improvement, but it helps a little) - MP3 files are detected; additional info is displayed for them (which is probably the nicest thing about NcdT) The info is displayed in a compact form, like <2:53 v168JR+> where 2:53 is play time, v (if present) means the file is encoded using VBR, 168 is bitrate (average bitrate for VBR files), J describes channel encoding (Mono, Stereo, Joint-Stereo, Dual channel), R (if present) means the file has a RIFF header at the beginning, + (if present) means the file has ID3v2 tag attached - (if present) means there's no ID3 tag at all (none of these means there's only ID3v1 tag present). NcdT is particularily nice for indexing CDs. OPTIONS
-d --dirs Print only directories, omit files. This mode is a rough equivalent of du(1). -b --bitrate Print bitrate info for directories. Bitrates are displayed both for ordinary files and directories. If all MP3 files in a given directory subtree have the same bitrate only one number is printed, if they have various bitrates the range is printed. --prefix text Prefix listing with given text. This option is not intended for general use. It might be used by programs using NcdT to index CDsor doing similar operations to record additional information. -? --help Display usage summary. USAGE
When called without any parameters ncdt displays directory tree for current directory (.). When called with one parameter ncdt displays directory tree for specified directory. When called with two parameters ncdt displays directory tree for the directory specified as its first parameter. Second parameter is used as directory label for the top level directory (instead of directory name from parameter 1). EXAMPLES
ncdt prints directory tree for the current directory. It will be labeled . ncdt /usr prints directory tree of /usr. It will be labeled /usr ncdt /cdrom 'CD #21' prints directory tree of /cdrom. It will be labeled CD #21 ncdt -db /cdrom lists directory sizes, play times and bitrate ranges SEE ALSO
tree(1), du(1) BUGS
NcdT uses quite a lot of memory. It's also not very fast, but on a decent CPU it should not be noticeable. There are no real bugs I'm aware of. I don't think there are any now. AUTHOR
Pawel Wiecek <coven@vmh.net> NcdT(1)
All times are GMT -4. The time now is 07:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy