Sponsored Content
Top Forums Shell Programming and Scripting Passing awk variables to shell Post 302603359 by urello on Wednesday 29th of February 2012 08:56:12 PM
Old 02-29-2012
Input file:
Code:
    Account Owner     : me
        Description       : me myself
        Login               : mylogin
        ID                   : 43303993
        Application       : test
        UID Number        : 3017256
        Password          : (encrypted)ololo
        Primary Group     : (451) testunix
        Secondary Group   : dialer wheel webgroup
        Home Directory    : /home/me
        Login Shell       : /usr/bin/ksh

I want to assign to variables value of fields "Primary Group" "Secondary Group" "Home Directory" "Login Shell". "Secondary Group" value could contain spaces
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing Variables to AWK

Does anybody have an explanation for the following: The following scripts runs fine on IRIX64 6.5 but has bugs on Solaris 8. #! /bin/sh echo run only on an SGI machine echo type in linenumber read j echo value read value awk -f rmspass2 level=$value $j'step1.mlf' When the script is... (5 Replies)
Discussion started by: AreaMan
5 Replies

2. Shell Programming and Scripting

Passing shell variables to awk program..

Hello, Can we pass shell variables like $PATH etc. to a awk program part for example, awk ' { fieldValue=$PATH .... }' file (1 Reply)
Discussion started by: Vishnu
1 Replies

3. Shell Programming and Scripting

Passing Variables to Awk

Hi I have a unix shell script with an awk statement. I would like to print some of the fields of an input file. However, I would like to print them dynamically, ie by passing the literal $1 $3 into the script to define the output. I have tried the following: variable1='$1' awk... (2 Replies)
Discussion started by: Bab00shka
2 Replies

4. Shell Programming and Scripting

Passing awk Variables

I am trying to pass the results from a variable gathered from awk, however when I echo the 'PARSE' and 'SUB', the response is blank. This is my command. awk -F= '/Unit/''{ PARSE=substr($2,1,5) ; SUB=substr($2,1,1) }' inputfile.lst Is this a kind of valid attempt or am I obligated to declare... (3 Replies)
Discussion started by: gozer13
3 Replies

5. UNIX for Dummies Questions & Answers

Passing Shell Variables to an awk command

Hello, I have two files File1 & File2. File1 76 135 136 200 250 345 .... File2 1 24 1 35 1 36 1 72 .... I want to get all the values form File2 corresponding to the range in File 1 and feed it to a program. Is the code below right? Can I pass shell variables to awk in this... (2 Replies)
Discussion started by: Gussifinknottle
2 Replies

6. Shell Programming and Scripting

ksh passing to awk multiple dyanamic variables awk -v

Using ksh to call a function which has awk script embedded. It parses a long two element list file, filled with text numbers (I want column 2, beginning no sooner than line 45, that's the only known thing) . It's unknown where to start or end the data collection, dynamic variables will be used. ... (1 Reply)
Discussion started by: highnthemnts
1 Replies

7. Shell Programming and Scripting

Passing variables into AWK

I'm trying to use awk to write new entries to a hosts file if they don't exist. I need to do so depending on the type of system I have. Below is what I have, but it isn't working. awk -v myip1=$IP1 myip2=$IP2 myhost1=$HOST1 myhost2=$HOST2' BEGIN { mqhost1=0; mqhost2=0; stap1=0; stap2=0; } ... (4 Replies)
Discussion started by: Boomn4x4
4 Replies

8. UNIX for Dummies Questions & Answers

Passing Global Shell variables to awk

Hi All, Iam trying to pass global shell variables and is not working Main script is like below CYEAR=`date +"%y"` CFYEAR=`date +"%Y"` CMONTH=`date +"%m"` if then PMONTH=12 PYEAR=`expr $CYEAR - 1` PFYEAR=`expr $CFYEAR - 1` else PMONTH=`expr... (6 Replies)
Discussion started by: baanprog
6 Replies

9. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

10. Shell Programming and Scripting

Awk: passing shell variables through and extracting text

Hello, new to the forums and to awk. Glad to be here. :o I want to pass two shell (#!/bin/sh) variables through to awk and use them. They will determine where to start and stop text extraction. The code with the variables hard-coded in awk works fine; the same code, but with the shell... (7 Replies)
Discussion started by: bedtime
7 Replies
CHPASS(1)						    BSD General Commands Manual 						 CHPASS(1)

NAME
chpass, chfn, chsh -- add or change user database information SYNOPSIS
chpass [-a list] [-s newshell] [-l] [user] chpass [-a list] [-s newshell] [-y] [user] DESCRIPTION
chpass allows editing of the user database information associated with user or, by default, the current user. The information is formatted and supplied to an editor for changes. Only the information that the user is allowed to change is displayed. The options are as follows: -a The super-user is allowed to directly supply a user database entry, in the format specified by passwd(5), as an argument. This argu- ment must be a colon (``:'') separated list of all the user database fields, although they may be empty. -s The -s option attempts to change the user's shell to newshell. -l This option causes the password to be updated only in the local password file. When changing only the local password, pwd_mkdb(8) is used to update the password databases. -y This forces the YP password database entry to be changed, even if the user has an entry in the local database. The rpc.yppasswdd(8) daemon should be running on the YP master server. Possible display items are as follows: Login: user's login name Password: user's encrypted password Uid: user's login Gid: user's login group Change: password change time Expire: account expiration time Class: user's general classification Home Directory: user's home directory Shell: user's login shell Full Name: user's real name Location: user's normal location Home Phone: user's home phone Office Phone: user's office phone The login field is the user name used to access the computer account. The password field contains the encrypted form of the user's password. The uid field is the number associated with the login field. Both of these fields should be unique across the system (and often across a group of systems) as they control file access. While it is possible to have multiple entries with identical login names and/or identical user id's, it is usually a mistake to do so. Rou- tines that manipulate these files will often return only one of the multiple entries, and that one by random selection. The group field is the group that the user will be placed in at login. Since BSD supports multiple groups (see groups(1)) this field cur- rently has little special meaning. This field may be filled in with either a number or a group name (see group(5)). The change field is the date by which the password must be changed. The expire field is the date on which the account expires. Both the change and expire fields should be entered in the form ``month day year'' where month is the month name (the first three characters are sufficient), day is the day of the month, and year is the year. The class field is a key for a user's login class. Login classes are defined in login.conf(5), which is a termcap(5) style database of user attributes, accounting, resource and environment settings. The user's home directory is the full UNIX path name where the user will be placed at login. The shell field is the command interpreter the user prefers. If the shell field is empty, the Bourne shell, /bin/sh, is assumed. When altering a login shell, and not the super-user, the user may not change from a non-standard shell or to a non-standard shell. Non-standard is defined as a shell not found in /etc/shells. The last four fields are for storing the user's full name, office location, and home and work telephone numbers. Once the information has been verified, chpass uses pwd_mkdb(8) to update the user database. ENVIRONMENT
The vi(1) editor will be used unless the environment variable EDITOR is set to an alternative editor. When the editor terminates, the infor- mation is re-read and used to update the user database itself. Only the user, or the super-user, may edit the information associated with the user. FILES
/etc/master.passwd The user database /etc/passwd A Version 7 format password file /etc/ptmp Lock file for the passwd database /tmp/pw.XXXXXX Temporary copy of the user passwd information /etc/shells The list of approved shells SEE ALSO
finger(1), login(1), passwd(1), pwhash(1), getusershell(3), passwd(5), passwd.conf(5), pwd_mkdb(8), vipw(8) Robert Morris and Ken Thompson, UNIX Password Security. HISTORY
The chpass command appeared in 4.3BSD-Reno. BUGS
This program's interface is poorly suited to cryptographic systems such as Kerberos, and consequently Kerberos password changing is not a feature of this program. User information should (and eventually will) be stored elsewhere. BSD
October 7, 2006 BSD
All times are GMT -4. The time now is 07:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy