Sponsored Content
Top Forums Shell Programming and Scripting Splitting multiple fields of /usr/bin/id Post 302994996 by RudiC on Thursday 30th of March 2017 10:12:45 AM
Old 03-30-2017
  1. /.../ is a regular expression; c.f. man awk: "Regular expressions are enclosed in slashes". A single / is pointless.
    ^ anchors the regex at begin-of-line (or string).
    .* represents "any char, zero or more times".
    = terminates this special regex. As we are sure there's only ONE = in $1, no additional measures need to be taken.
    | is the alternation operator ("or"), so multiple regexes can be matched
  2. Yes, that's why I used two function calls: for different results. If you accept leading and trailing spaces, try gsub (/^.*=|\)|\(/, " ", $1) and drop the sub.
  3. Semicolons separate commands in awk, as do line feeds. gsub modifies $1, then sub works on that mod'd $1
This User Gave Thanks to RudiC For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

/bin/sh: /usr/bin/vi: No such file or directory when doing crontab

I just set up an ftp server with Red Hat 5.2. I am doing the work, I'm baby stepping, but it seems like every step I get stuck. Currently, I'm trying to set up a crontab job, but I'm getting the following message: /bin/sh: /usr/bin/vi: No such file or directory. I see that vi exists in /bin/vi,... (3 Replies)
Discussion started by: kwalter
3 Replies

2. UNIX for Dummies Questions & Answers

Difference between /bin, /usr/bin, /sbin ?

Hi All, Can somebody tell me the difference between /bin, /usr/bin, /sbin ? Thanx in advance, Saneesh Joseph (3 Replies)
Discussion started by: saneeshjose
3 Replies

3. Solaris

How do I link ld in /usr/ucb/ to /usr/ccs/bin?

Hi all, below is the problem details: ora10g@CNORACLE1>which ld /usr/ucb/ld ora10g@CNORACLE1>cd /usr/ccs/bin ora10g@CNORACLE1>ln -s /usr/ucb/ld ld ln: cannot create ld: File exists ora10g@CNORACLE1> how to link it to /usr/ccs/bin? (6 Replies)
Discussion started by: SmartAntz
6 Replies

4. UNIX for Dummies Questions & Answers

Alias /usr/bin to /bin in profile

Hi! All the basic linux commands, ie. echo, find, etc, are located in /bin. I have a couple of programs that have these commands pointed towards /usr/bin, ie, /usr/bin/echo (even though the actual 'echo' command is in /bin). How can I alias or redirect or link the /usr/bin to /bin just for this... (6 Replies)
Discussion started by: dancerat
6 Replies

5. OS X (Apple)

When to use /Users/m/bin instead of /usr/local/bin (& whats the diff?)?

Q1. I understand that /usr/local/bin means I can install/uninstall stuff in here and have any chance of messing up my original system files or effecting any other users. I created this directory myself. But what about the directory I didn't create, namely /Users/m/bin? How is that directory... (1 Reply)
Discussion started by: michellepace
1 Replies

6. Solaris

What is the difference between xpg4/bin and usr/bin?

Hi Experts, I found that the same commands(sort, du, df, find, grep etc.) exists in both dir. What is the difference to use them? i.e: to use xpg4/bin/grep and usr/bin/grep My OS version is SunOS 5.10 Regards, Saps (7 Replies)
Discussion started by: saps19
7 Replies

7. Solaris

How to link sed from /usr/bin/sed to /usr/local/bin/sed?

Hi Guys, OS:- Solaris 10 64Bit I have a small query. On one server a user is facing sed command issue. He gets error regarding sed for this location /users/hoy/2999/batch5/bin/internal.sh: /usr/local/bin/sed: not found How ever the sed is actually present at this location on server:-... (13 Replies)
Discussion started by: manalisharmabe
13 Replies

8. Shell Programming and Scripting

Splitting a filed into multiple fields using awk

Hi, I have a tab delimited file as below: AWA Divi DD01 None 1 2 Room AC 01-MAY-15 31-OCT-15 OT 01-MAY-15 31-OCT-15 CF 01-MAY-15 31-OCT-15 AW0 Beach DD02 None 1 2 Double AC 01-MAY-15 31-OCT-15 AD 01-MAY-15 31-OCT-15 The number of columns(fields) after 7th field is not fixed and... (3 Replies)
Discussion started by: Bobby_2000
3 Replies

9. BSD

FreeBSD: /usr/bin/ld not looking in /usr/local/lib

I'm not sure if this is the default behavior for the ld command, but it does not seem to be looking in /usr/local/lib for shared libraries. I was trying to compile the latest version of Kanatest from svn. The autorgen.sh script seems to exit without too much trouble: $ ./autogen.sh checking... (2 Replies)
Discussion started by: AntumDeluge
2 Replies
id(1)							      General Commands Manual							     id(1)

NAME
id - Displays the user's system identity SYNOPSIS
id [user] id -G [-n] [user] id -g [-nr] [user] id -u [-nr] [user] id -a STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: id: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
Displays all groups ids (real, effective, and supplementary) only, as unsigned decimal numbers. Displays only the effective group id as an unsigned decimal number. Displays user and group names as strings rather than as numbers. Displays only the real ID. Displays only the effective user ID as an unsigned decimal number. [Tru64 UNIX] Displays user and all group IDs and names if the environment variable CMD_ENV is set to the string svr4. OPERANDS
The user for whom information is to be written. If this parameter is omitted, the user and group names associated with the invoking process are used. DESCRIPTION
The id command writes to standard output a message containing the user and group IDs and corresponding names of the invoking process. If effective names and IDs do not match the real ones, the id command writes both. If user is specified and the invoking process has sufficient privileges, the IDs and names in the message are for user rather than for the invoking process. Effective IDs are assumed identical to real IDs. Your real user and group ids are specified in the /etc/passwd file and are your user and group ids on login. You can change your active group with the newgrp shell command (see newgrp(1)) if additional groups are specified for you in the /etc/group file. Such groups are called supplementary . A process can also have an effective user or group id set when a set-user- or set-group-identifier program is executed. See setuid(2), setgid(2). SVID Conformance [Tru64 UNIX] When the environment variable CMD_ENV is set to the string svr4, the command syntax and output is compatible with the SVID standard. In particular, the id command with no options displays the user's name and id and the real and effective group names and ids. The -a option adds any supplementary group names and ids to the display. EXIT STATUS
The following exit values are returned: Successful completion. An error occurred. EXAMPLES
To display your user and group IDs, enter: id Information is displayed similar to: uid=200(thomas) gid=1(staff) In the case where a user belongs to a supplementary group, information is displayed similar to: uid=200(thomas) gid=1(staff) groups=0(system) However, if the environment variable CMD_ENV is set to the string svr4, the command id with no options does not display any supple- mentary groups and results in a display similar to: uid=200(thomas) gid=1(staff) To display supplementary groups with CMD_ENV set to svr4, use the command id -a. The display is then similar to: uid=200(thomas) gid=1(staff) groups=1(users),0(system) ENVIRONMENT VARIABLES
The following environment variables affect the execution of id: [Tru64 UNIX] When this environment variable CMD_ENV is set to the string svr4, the command syntax and output is compatible with the SVID standard. The -a option is only available in this condition. Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization variables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the format and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. FILES
Group names declared on the system. Password file. SEE ALSO
Commands: groups(1), logname(1), newgrp(1), who(1) Functions: getgid(2), getuid(2), setgid(2), setuid(2) Files: group(4), passwd(4) Environment: environ(5) Standards: standards(5) id(1)
All times are GMT -4. The time now is 08:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy