Sponsored Content
Top Forums Shell Programming and Scripting Longest length of string in array Post 302581914 by mmab on Wednesday 14th of December 2011 10:47:33 AM
Old 12-14-2011
Again, i've confussed things, sorry. The padding of the 2nd column is based on a defined scalar variable, like so;

Code;
m=6
printf "%s %-${m}g %s\n" 'text' 'martin' 'text'
printf "%s %-${m}g %s\n" 'text' 'ian' 'text'

Output;

text martin text
text Ian___text (underscores represent spaces)

I know the above code is wrong but wrote it to give an idea of what i'm trying to achieve.

Regards
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find the length of the longest line

Dear All, To find the length of the longest line from a file i have used wc -L which is giving the proper output... But the problem is AIX os does not support wc -L command. so is there any other way 2 to find out the length of the longest line using awk or sed ? Regards, Pankaj (1 Reply)
Discussion started by: panknil
1 Replies

2. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

3. Shell Programming and Scripting

Find longest string and print it

Hello all, I need to find the longest string in a select field and print that field. I have tried a few different methods and I always end up one step from where I need to be. Methods thus far: nawk '{if (length($1) > long) long=length($1); if(length($1)==long) print $1}' The above... (6 Replies)
Discussion started by: SEinT
6 Replies

4. Programming

How to find length of string and pass into char array in C?

Hi All I want to take a Hexadecimal number as input and i want to find lenth of the input and pass it to char s ( char s ). I have a program to convert hexadecial to binary but it is taking limited input but i want to return binary number based on input. How? (1 Reply)
Discussion started by: atharalikhan
1 Replies

5. UNIX for Dummies Questions & Answers

Display all the words whose length is equal to the longest word in the text

Hi Guys, I was going some trial and error to see if I can find the longest word in a text. I was using Pipes because they are easier to use in this case. I was stuck on this for a while so I thought I'll get some help with it. I tried this code to separate all the words in a text in... (4 Replies)
Discussion started by: bawse.c
4 Replies

6. Shell Programming and Scripting

awk uniq and longest string of a column as index

I met a challenge to filter ~70 millions of sequence rows and I want using awk with conditions: 1) longest string of each pattern in column 2, ignore any sub-string, as the index; 2) all the unique patterns after 1); 3) print the whole row; input: 1 ABCDEFGHI longest_sequence1 2 ABCDEFGH... (12 Replies)
Discussion started by: yifangt
12 Replies

7. Shell Programming and Scripting

Array Length Reports as Having Length when it is Empty?

Hello All, I have this script that does stuff like "starting, stopping & restarting" a Daemon Process running on my machine... My main question is why in part of my code (which you will see below) does the Array Length (i.e. ${#PIDS} ) return "1" when I know the Array is empty..? Here is... (17 Replies)
Discussion started by: mrm5102
17 Replies

8. Shell Programming and Scripting

Finding the length of the longest column

Hi, I am trying to figure out how to get the length of the longest column in the entire file (because the length varies from one row to the other) I was doing this at first to check how many fields I have for the first row: awk '{print NF; exit}' file Now, I can do this: awk '{ if... (4 Replies)
Discussion started by: MIA651
4 Replies

9. Shell Programming and Scripting

wc -L giving incorrect length of longest line

Running below line gives 3957 as length of longest line in file 20121119_SRMNotes_init.dat awk ' { if ( length > 3950 ) { x = length } }END{ print x }' 20121119_SRMNotes_init.dat While wc -L 20121119_SRMNotes_init.dat gives output as 4329. Why is there a difference between these two commands.... (2 Replies)
Discussion started by: Satish Mantha
2 Replies

10. Shell Programming and Scripting

Parse the longest matching string

Hello experts, I am trying to unscramble a mixed signal into component signals. Let the list of known signals be $ cat tmplist DU DU4016 GFF GFF2010 GFF201019 G2115 G211 DU40 (1 Reply)
Discussion started by: senhia83
1 Replies
glib-mkenums(1) 						   User Commands						   glib-mkenums(1)

NAME
glib-mkenums - generate C language enum description SYNOPSIS
glib-mkenums [--comments text] [--eprod text] [--fhead text] [--fprod text] [--ftail text] [--help] [--version] [--vhead text] [--vprod text] [--vtail text] [file...] DESCRIPTION
glib-mkenums parses C code to extract enum definitions, and produces enum descriptions based on text templates specified by the user. glib- mkenums produces C code that contains enum values as strings, which allows programs to provide value name strings. EXTENDED DESCRIPTION
This section provides more information about text substitution and trigraph extensions. Text Substitution glib-mkenums substitutes certain keywords, which are enclosed in @ characters, when creating the output text. For the substitution examples of the keywords in this section, the following example enum definition is assumed: typedef enum { PREFIX_THE_XVALUE = 1 << 3, PREFIX_ANOTHER_VALUE = 1 << 4 } PrefixTheXEnum; glib-mkenums substitutes the following keywords: @EnumName@ The name of the enum currently being processed. enum names are assumed to be properly namespaced and to use mixed capitalization to separate words (for example, PrefixTheXEnum). @enum_name@ The enum name with words in lowercase and each word separated by underscores (for example, prefix_the_xenum). @ENUMNAME@ The enum name with words in uppercase and each word separated by underscores (for example, PREFIX_THE_XENUM). @ENUMSHORT@ The enum name with words in uppercase and each word separated by underscores, and with the prefix stripped (for example, THE_XENUM). @VALUENAME@ The enum value name currently being processed, with words in uppercase and each word separated by underscores. This is the assumed literal notation of enum values in the C sources (for example, PREFIX_THE_XVALUE). @valuenick@ A nickname for the enum value currently being processed. This is usually generated by stripping the common prefix words of all of the enum values of the current enum, with words in lowercase and underscores substituted by hyphens (for example, the-xvalue). @type@ This is substituted either by enum or flags, depending on whether the enum value definitions contain bit-shift operators or not (for example, flags). @Type@ Same as @type@, but with the first letter capitalized (for example, Flags). @TYPE@ Same as @type@, but with all letters in uppercase (for example, FLAGS). @filename@ The name of the input file currently being processed (for example, foo.h). Trigraph Extensions Some C comments in the parsed enum definitions are treated as special. Such comments start with the trigraph sequence /*< and end with the trigraph sequence >*/. Per enum definition, the skip and flags options are supported. The skip option indicates that this enum definition should be skipped. The flags option specifies that this enum definition should be treated as a flags definition, or specifies the common prefix to be stripped from all values to generate value nicknames. Per value definition, the skip and nick options are supported. The skip option causes the value to be skipped. The nick option specifies the otherwise autogenerated nickname. OPTIONS
The following options are supported: --comments text Output text. --eprod text Output text every time an enum occurs in the input files. --fhead text Output text prior to processing input files. --fprod text Output text every time a new input file is processed. --ftail text Output text when all input files have been processed. --help Show usage and basic help information. --version Show version information. --vhead text Output text before iterating the set of values of an enum. --vprod text Output text for every value of an enum. --vtail text Output text after iterating all values of an enum. OPERANDS
The following operands are supported: file Specifies a valid C code file. EXAMPLES
Example 1: Examples of Trigraph Extensions typedef enum /*< skip >*/ { PREFIX_FOO } PrefixThisEnumWillBeSkipped; typedef enum /*< flags,prefix=PREFIX >*/ { PREFIX_THE_ZEROTH_VALUE, /*< skip >*/ PREFIX_THE_FIRST_VALUE, PREFIX_THE_SECOND_VALUE, PREFIX_THE_THIRD_VALUE, /*< nick=the-last-value >*/ } PrefixTheFlagsEnum; EXIT STATUS
The following exit values are returned: 0 Application exited successfully >0 Application exited with failure FILES
The following files are used by this application: /usr/bin/glib-mkenums The command-line executable for the application. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWgnome-base-libs-devel | +-----------------------------+-----------------------------+ |Interface stability |External | +-----------------------------+-----------------------------+ SEE ALSO
glib-genmarshal(1), libglib-2.0(3) NOTES
Updated by Brian Cameron, Sun Microsystems Inc., 2003. Written by Tim Janik. SunOS 5.10 7 Apr 2003 glib-mkenums(1)
All times are GMT -4. The time now is 01:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy