making the first character of word using uppercase using awk and sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting making the first character of word using uppercase using awk and sed
Prev   Next
# 1  
Old 10-17-2011
making the first character of word to uppercase using awk and sed

I want to make the first character of some words to be uppercase. I have a file like the one below.

uid,givenname,sn,cn,mail,telephonenumber
mattj,matt,johnson,matt johnson,mattj@gmail.com
markv,mark,vennet,matt s vennet,markv@gmail.com
mikea,mike,austi,mike austin,mike@gmail.com

I want to make the 2nd,3rd and 4th fields to start with upper case. Second entry has a middle initial which has to made an uppercase too. Entries from the second row should be modified till the end of the file for all the entries. What would be the easiest way to do this. expected result is.

uid,givenname,sn,cn,mail,telephonenumber
mattj,Matt,Johnson,Matt Johnson,mattj@gmail.com
markv,Mark,Vennet,Matt S Vennet,markv@gmail.com
mikea,Mike,Austi,Mike Austin,mike@gmail.com

Thanks
Matt

Last edited by matt12; 10-17-2011 at 10:14 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding a word with awk or sed

Hello, in a AIX system : AIX CDRATE01 2 7 00FAB3114C00 my following commande give the result : LISTE /tmp/RESS **************************************************************** Liste TYPE = XXXXXXX EX = YYYY VER ... (13 Replies)
Discussion started by: sam01
13 Replies

2. Shell Programming and Scripting

SED (or other) upper to lowercase, with first letter of first word in each sentence uppercase

The title pretty much defines the problem. I have text files that are all in caps. I would like to convert them to lowercase, but have the first letter of the first word in each sentence in uppercase. I already have SED on the server for fixing / tweaking text files, but I'm open to other... (5 Replies)
Discussion started by: dockline
5 Replies

3. Shell Programming and Scripting

Making use of multiple cores for running sed and awk scripts

Hi All, After reading that the sort command in Linux can be made to use many processor cores just by using a simple script which I found on the internet, I was wondering if I can use similar techniques for programs like the awk and sed? #!/bin/bash # Usage: psort filename <chunksize>... (7 Replies)
Discussion started by: shoaibjameel123
7 Replies

4. Shell Programming and Scripting

sed or awk to print 2nd last word

Hi, I have a file which has the following /usr/new/xyz/abc /us1/neb/yxr/def /usr/bin/cloud1/fgh /net/bin1/txt1/kdq I want to do something like this /usr/new/xyz/abc xyz /us1/neb/yxr/def yxr /usr/bin/cloud1/fgh cloud1 /net/bin1/txt1/kdq txt1 I need to add the 2nd last word to the... (3 Replies)
Discussion started by: matbrow
3 Replies

5. Shell Programming and Scripting

Make the first character uppercase

Input: hello world monkey Output should be: Hello World Monkey How can it be done with perl,sed,awk or bash? (9 Replies)
Discussion started by: cola
9 Replies

6. Shell Programming and Scripting

Getting the first word using sed,awk or perl

Input: root:x:0: daemon:x:1: bin:x:2: sys:x:3: adm:x:4: tty:x:5: disk:x:6: lp:x:7: mail:x:8: Output: root daemon bin sys adm tty (8 Replies)
Discussion started by: cola
8 Replies

7. Shell Programming and Scripting

Uppercase/lowercase comparison of one character per line with awk??

Another frustrating scripting problem from a biologist trying to manipulate a file with several millions line. For each of the line I need to compare the uppercase A or C or G or T with the lowercase a or c or g or t. If there are more uppercases, a + should be added to a new column, otherwise a -... (10 Replies)
Discussion started by: ivpz
10 Replies

8. Shell Programming and Scripting

Uppercase word in PERL

how do i print uppercase words in a string in PERL For example $str=" welcome to UNIX programming" should print UNIX $str="WELCOME to unix programming" should print WELCOME i itried the following /\s+\w+\b/ $str Can u help me in to get a uppercase word in PERL (3 Replies)
Discussion started by: vkca
3 Replies

9. UNIX for Dummies Questions & Answers

using grep and to remove all word with uppercase

I try to write a small script that looks in the file tt for all the words that start with m in lowercase and in which there is no uppercase. #!/bin/sh grep ^m\.*\.\.* tt (4 Replies)
Discussion started by: cfg
4 Replies

10. Shell Programming and Scripting

only uppercase first character?

should be a simple question, I am trying to uppercase every first character in a word on the list. abc google cnn services My first thought was sed 'y/^/^/', but it changed all the characters, not just the first character. any thoughts? (7 Replies)
Discussion started by: fedora
7 Replies
Login or Register to Ask a Question
MUTT_LDAP_QUERY(1)					User Contributed Perl Documentation					MUTT_LDAP_QUERY(1)

NAME
mutt_ldap_query - Query LDAP server for Mutt mail-reader SYNOPSIS
mutt_ldap_query.pl [options] <name_to_query> [[<other_name_to_query>] ...] OPTIONS
--config=config_file or -c config_file specify an alternate resource file other than the system ones (/etc/lbdb_ldap.rc or /etc/mutt_ldap_query.rc) or default personal ones ($HOME/.lbdb/ldap.rc or $HOME/.mutt_ldap_query.rc). --server=ldap_server or -ls ldap_server hostname of your ldap server. You can also use an ldap://foo[:port] or ldaps://foo[:port] URL here to talk to different ports or SSL encrypted servers. Or use ldapi://%2fvar%2flib%2fldap_sock to access an ldap server via a socket (use %2f as as replacement for a slash in the file name). --search_base=ldap_search_base or -sb ldap_search_base use <search_base> as the starting point for the search instead of the default. --search_fields=ldap_search_fields or -sf ldap_search_fields list of the fields on which the query will be performed. --expected_answers=ldap_expected_answers or -ea ldap_expected_answers list of the fields expected as the answer of the ldap server that will be used for composing the output of the script. --format_email=result_format_email or -fe result_format_email format to be used for composing the email output result. It has to be based on the expected ldap server answers and can use variable containers of the form ${variable} where variable belongs to the <ldap_expected_answers> set. --format_realname=result_format_realname or -fr result_format_realname format to be used for composing the realname output result. It has to be based on the expected ldap server answers and can use variable containers of the form ${variable} where variable belongs to the <ldap_expected_answers> set. --format_comment=result_format_comment or -fc result_format_comment format to be used for composing the comment output result. It has to be based on the expected ldap server answers and can use variable containers of the form ${variable} where variable belongs to the <ldap_expected_answers> set. --bind_dn=bind_distinguished_name or -bd bind_distinguished_name the destinguished name of the user who binds to the LDAP server. Leave it empty for an anonmyous bind. --bind_password=secret or -bp secret the bind password for binding to the LDAP server. Leave it empty for an anonmyous bind. --nickname=ldap_server_nickname or -n ldap_server_nickname shortcut for avoiding to use all the previous options by using the script builtin or alternate config file table of common servers and associated options. All the required parameters are then derived by performing a <lbdb_server_nickname> lookup. --debug or -d turn on debugging messages. --help or -? or -h or --man or -m generates this help message. --ignorant or -i ignorant mode: search using wildcard for *name_to_query* (requires a longer processing from LDAP server but is quite convenient :). --lbdb_output or -l suppress number of matches output (suited for interfacing with little brother database http://www.spinnaker.de/lbdb/). --version or -v show the version. DESCRIPTION
mutt_ldap_query performs ldap queries using either ldapsearch command or the perl-ldap module and it outputs the required formatted data for feeding mutt when using its "External Address Query" feature. The output of the script consists in 3 fields separated with tabs: the email address, the name of the person and a comment. INTERFACING WITH MUTT
This perl script can be interfaced with mutt by defining in your .muttrc: set query_command = "mutt_ldap_query.pl %s" Multiple requests are supported: the "Q" command of mutt accepts as argument a list of queries (e.g. "Gosse de Courville"). Alternatively mutt_ldap_query can be interfaced with the more generic little brother database query program (http://www.spinnaker.de/lbdb/) using: set query_command = "lbdbq %s" and by specifying in your ~/.lbdb/lbdbrc file another method of query just adding to the METHODS variable the m_ldap module e.g.: METHODS='m_inmail m_passwd m_ldap m_muttalias m_finger' and the right path to access m_ldap in MODULES_PATH, e.g. if you moved m_ldap in ~/.lbdb/modules: MODULES_PATH="/usr/local/lib $HOME/.lbdb/modules" Just make sure to use the correct path for calling mutt_ldap_query in the m_ldap script. RESOURCE FILE FORMAT
mutt_ldap_query is now fully customizable using an external resource file. By default mutt_ldap_query parses the system definition file located generally at /etc/mutt_ldap_query.rc or /usr/local/etc/mutt_ldap_query.rc and also the user one: $HOME/.mutt_ldap_query.rc. Instead of using command line options, the user can redefine all the variables using the resource file by two manners in order to match his site configuration. A file example is provided below: # The format of each entry of the ldap server database is the following: # LDAP_NICKNAME => ['LDAP_SERVER', # 'LDAP_SEARCH_BASE', # 'LDAP_SEARCH_FIELDS', # 'LDAP_EXPECTED_ANSWERS', # 'LDAP_RESULT_EMAIL', # 'LDAP_RESULT_REALNAME', # 'LDAP_RESULT_COMMENT'], # a practical illustrating example being: # debian => ['db.debian.org', # 'ou=users,dc=debian,dc=org', # 'uid cn sn ircnick', # 'uid cn sn ircnick', # '${uid}@debian.org', # '${cn} ${sn}', # '${ircnick}'], # the output of the query will be then: # ${uid}@debian.org ${cn} ${sn} ${ircnick} (i.e.: email name comment) # warning this database will erase default script builtin %ldap_server_db = ( 'four11' => ['ldap.four11.com', 'c=US', 'givenname sn cn mail', 'givenname cn sn mail o', '${mail}', '${givenname} ${sn}', '${o}' ], 'infospace' => ['ldap.infospace.com', 'c=US', 'givenname sn cn mail', 'givenname cn sn mail o', '${mail}', '${givenname} ${sn}', '${o}' ], 'whowhere' => ['ldap.whowhere.com', 'c=US', 'givenname sn cn mail', 'givenname cn sn mail o', '${mail}', '${givenname} ${sn}', '${o}' ], 'bigfoot' => ['ldap.bigfoot.com', 'c=US', 'givenname sn cn mail' , 'givenname cn sn mail o' , '${mail}' , '${givenname} ${sn}', '${o}' ], 'switchboard' => ['ldap.switchboard.com', 'c=US', 'givenname sn cn mail' , 'givenname cn sn mail o', '${mail}', '${givenname} ${sn}', '${o}' ], 'infospacebiz' => ['ldapbiz.infospace.com', 'c=US', 'givenname sn cn mail', 'givenname cn sn mail o', '${mail}', '${givenname} ${sn}', '${o}' ], ); # hostname of your ldap server $ldap_server = 'ldap.four11.com'; # ldap base search $search_base = 'c=US'; # list of the fields that will be used for the query $ldap_search_fields = 'givenname sn cn mail'; # list of the fields that will be used for composing the answer $ldap_expected_answers = 'givenname sn cn mail o'; # format of the email result based on the expected answers of the ldap query $ldap_result_email = '${mail}'; # format of the realname result based on the expected answers of the ldap query $ldap_result_realname = '${givenname} ${sn}'; # format of the comment result based on the expected answers of the ldap query $ldap_result_comment = '(${o})'; EXAMPLES OF QUERIES
mutt_ldap_query.pl --ldap_server='ldap.mot.com' --search_base='ou=employees, o=Motorola,c=US' --ldap_search_fields='commonName gn sn cn uid' --ldap_expected_answers='gn sn preferredRfc822Recipient ou c telephonenumber' --ldap_result_email='${preferredRfc822Recipient}' --ldap_result_realname='${gn} ${sn}' --ldap_result_comment='(${telephonenumber}) ${ou} ${c}' Gosse de Courville performs a query using the ldap server ldap.mot.com using the following searching base 'ou=employees, o=Motorola,c=US' and performing a search on the fields 'commonName gn sn cn uid' for 'Gosse' and then "de Courville" looking for the following answers 'gn sn preferredRfc822Recipient ou c telephonenumber'. Based on this answers, mutt_ldap_query will return a list of entries identified of the form: <${preferredRfc822Recipient}> ${gn} ${sn} (${telephonenumber}) ${ou} ${c} where ${} variables should be considered as containers that are replaced by the results of the query. The previous query can be greatly simplified by using the ldap server mini database feature of the resource file introducing for example a nickname. mutt_ldap_query.pl --ldap_server_nickname='motorola' Gosse de Courville When not sure of the full name (i.e. it should contain Courville) the ignorant mode is useful since the query will be performed using wildcards, i.e. *Courville* in the following case: mutt_ldap_query.pl --ignorant Courville WHERE TO GET IT
The latest version can be retrieved at ftp://ftp.mutt.org/pub/mutt/contrib or http://www.courville.org/ Note that now the script is integrated in the latest version of the little brother database available at http://www.spinnaker.de/lbdb/. It is thus easier to use through this standard package than to hand customize it to fit your system/distribution needs. REFERENCES
- perl-ldap module http://perl-ldap.sourceforge.net/ - mutt is the ultimate email client http://www.mutt.org/ - historical Brandon Blong's "External Address Query" feature patch for mutt http://www.fiction.net/blong/programs/mutt/#query - little brother database is an interface query program for mutt that allow multiple searches for email addresses based on external query scripts just like this one 8-) http://www.spinnaker.de/lbdb/ AUTHORS
Marc de Courville <marc@courville.org> and the various other contributors... that kindly sent their patches. Please report any bugs, or post any suggestions, to <marc@courville.org>. COPYRIGHT
Copyright (c) 1998-2003 Marc de Courville <marc@courville.org>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the GNU General Public License (GPL). See http://www.opensource.org/gpl-license.html and http://www.opensource.org/. perl v5.10.1 2011-06-25 MUTT_LDAP_QUERY(1)