![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to parse a string into variables | aquimby | Shell Programming and Scripting | 9 | 06-12-2009 05:57 PM |
| How to: Parse text string into variables using Korn shell | shew01 | Shell Programming and Scripting | 7 | 05-23-2008 11:01 AM |
| splitting a record and adding a record to a file | rsolap | Shell Programming and Scripting | 1 | 08-13-2007 02:58 PM |
| How to parse config variables from external file to shell script | pradsh | Shell Programming and Scripting | 2 | 07-09-2007 03:21 PM |
| How do I parse passwords into passwd command. | gilberteu | Shell Programming and Scripting | 0 | 03-28-2006 12:26 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How can I parse a record found in /etc/passwd into variables?
I am working with the Oracle 10.2.0.3 job scheduler on Solaris 10, and unfortunately, the scheduler executes scripts in such a way that several default shell environment variables are not defined. For example, $HOME, $USER, and $LOGNAME are missing.
How can I parse the appropriate record in /etc/passwd into the above variables? For example, when the output from "grep oracle /etc/passwd" is: oracle:x:100:1978::/usr/oracle:/bin/kshI need to parse the information so that I can manually export the following variables: export HOME=/usr/oracleI'm looking for something generic that will enable me to search for any record in /etc/passwd and parse it properly. Thanks, J |
|
||||
|
Quote:
Code:
export HOME=$(nawk -F":" '/^oracle/{print $(NF-1)}' /etc/passwd)
export USER=$(nawk -F":" '/^oracle/{print $1}' /etc/passwd)
export LOGNAME=$(nawk -F":" '/^oracle/{print $1}' /etc/passwd)
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|