Is there a simple way to find the longest common prefix of a space-separated list of strings, optionally by field?
For example, given input:
with no field separator, output:
with _ field separator, output:
I have an awk solution which appears to work (although I haven't done much testing):
Searching didn't come up with anything more elegant that could handle both by character and by field. So, just wondering if the forum had any better solutions.
EDIT: The above (cygwin) doesn't seem to work very well on (non-gawk) AIX 6.1. Seems you can't fiddle with NF in END the way I've doing above (although just printing pcount fields of prefix works), and having a blank field separator seems equivalent to whitespace (i.e. it won't split by character).
Last edited by CarloM; 10-25-2013 at 04:45 AM..
Reason: Platforms
Thank you for assisting,
I've got a partial solution just needs a tweak.
Hulk-BASH$ cat somefile.txt
oh there is some stuff here
some more stuff here
START_LABEL
stuff I want
more stuff I want
END_LABEL
other stuff here too
and even more stuff here too
Hulk-BASH$
Hulk-BASH$ sed... (8 Replies)
Hi ,
I want to write a simple script.
I have two files
file1:
BCSpeciality
Backend
CB
CBAPQualDisp
CBCimsVFTRCK
CBDSNQualDisp
CBDefault
CBDisney
CBFaxMCGen
CBMCGeneral
CBMCQualDisp
file2:
CSpeciality
Backend (8 Replies)
Hi ,
I have a text file in the format
DB2:
DB2:
WB:
WB:
WB:
WB:
and a second text file of the format
Time=00:00:00.473
Time=00:00:00.436
Time=00:00:00.016
Time=00:00:00.027
Time=00:00:00.471
Time=00:00:00.436
the last string in both the text files is of the... (4 Replies)
Hi all,
I'd like you to help or give any advise about the following:
I have two (2) files, file1 and file2, both files have information common to each other. The contents of file1 is a subset of the contents of file2:
file1:
errormsgadmin
esdp
esgservices
esignipa
iprice
ipvpn
irm... (0 Replies)
Hi all,
I'd like you to help or give any advise about the following:
I have two (2) files, file1 and file2, both files have information common to each other. The contents of file1 is a subset of the contents of file2:
file1:
errormsgadmin
esdp
esgservices
esignipa
iprice
ipvpn
irm... (18 Replies)
I have a file say "example.xml" and the contents of this example.xml are
<project name="platform/packages/wallpapers/Basic" path="packages/wallpapers/Basic" revision="225e410f054c4ad5c828b0fec9be1b47c4376711"/>
<project name="platform/packages/wallpapers/Galaxy4"... (3 Replies)
Hi,
I am entirely new to Unix, need your help to perform certain actions in unix:
Can anyone please tell me how to list the number of files in UNIX with Common prefix name. "I want just the number of files and not the names of files".
Thanks (12 Replies)
Good day people,
Kindly advice what is the operator/command that I should try out to if I am about to return a list of prefix of my filename with first 6 character.
I understand I could use sed to retrieve the first 6 charter itself.
but i wonder if there is any aix command allow me to loop... (4 Replies)
Hello Everyone ,
Iam a newbie to shell programming and iam reaching out if anyone can help in this :-
I have two files
1) Insert.txt
2) partition_list.txt
insert.txt looks like this :-
insert into emp1 partition (partition_name)
(a1,
b2,
c4,
s6,
d8)
select
a1,
b2,
c4, (2 Replies)
Discussion started by: nubie2linux
2 Replies
LEARN ABOUT OPENSOLARIS
sasl_listmech
sasl_listmech(3SASL) Simple Authentication Security Layer Library Functions sasl_listmech(3SASL)NAME
sasl_listmech - retrieve a list of the supported SASL mechanisms
SYNOPSIS
cc [ flag ... ] file ... -lsasl [ library ... ]
#include <sasl/sasl.h>
int sasl_listmech(sasl_conn_t *conn, const char *user, const char *prefix,
const char *sep, const char *suffix, const char **result,
unsigned *plen,int *pcount);
DESCRIPTION
The sasl_listmech() interface returns a string listing the SASL names of all the mechanisms available to the specified user. This call is
typically given to the client through a capability command or initial server response. Client applications need this list so that they know
what mechanisms the server supports.
PARAMETERS
conn The SASL context for this connection user restricts the mechanism list to those mechanisms available to the user. This parameter
is optional.
user Restricts security mechanisms to those available to that user. The value of user may be NULL, and it is not used if called by the
client application.
prefix Appended to the beginning of result.
sep Appended between mechanisms.
suffix Appended to the end of result.
result A null-terminated result string. result must be allocated or freed by the library.
plen The length of the result filled in by the library. The value of plen may be NULL.
pcount The number of mechanisms available. The value of pcount is filled in by the library. The value of pcount may be NULL
RETURN VALUES
sasl_listmech() returns an integer that corresponds to a SASL error code.
ERRORS
SASL_OK The call to sasl_listmech() was successful.
See sasl_errors(3SASL) for information on SASL error codes.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWlibsasl |
+-----------------------------+-----------------------------+
|Interface Stability |Evolving |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO sasl_errors(3SASL), attributes(5)SunOS 5.11 14 Oct 2003 sasl_listmech(3SASL)