Sponsored Content
Homework and Emergencies Homework & Coursework Questions Display usernames and their UIDs Post 303018033 by baniel on Sunday 27th of May 2018 11:29:17 AM
Old 05-27-2018
Display usernames and their UIDs

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

Write a script that displays all usernames and their UIDs in the following fashion:
name1 uid=999
name2 uid=888
... ...

2. Relevant commands, code, scripts, algorithms:

grep, cut, id, echo, for...do...done

3. The attempts at a solution (include all code and scripts):

I managed to list usernames and UIDs but I can't figure out how to add "uid=" string. I've been coming back to this problem for the last two days but maybe my approach is wrong. Please, help Smilie
Since I don't have a Solaris or Linux on PC, I've tested the code on tutorialspoint/execute_ksh_online.

Code:
#!/bin/bash

sort -nr -t ':' -k3 /etc/passwd | cut -d: -f1,3

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Vistula University, Warsaw, Poland, Matusiak Sławomir, CII4SP16CI-L18

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
This User Gave Thanks to baniel For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

about UIDs, very urgent

hello guys, well as i mentioned first i have a serious problem, i need your help. i have a hosting plan with linux, apache and php. i have a script (that have my UID=32256) inside my web site (in the panel folder -see below-) that creates new scripts (in the pages folder) (the new scripts... (1 Reply)
Discussion started by: mehdi
1 Replies

2. UNIX for Advanced & Expert Users

Usernames and processes most used

I need a command that returns the usernames that have ran the 10 processes that have taken the most time to execute on a machine. I also need a command that returns only those directories that have read/execute permissions for all the users. (4 Replies)
Discussion started by: anw68ster
4 Replies

3. HP-UX

Valid ranges for uids for HP-UX

Hi , I am using adduser in hp-ux to create users in Hp-ux. i would like to know what are the valid values for uids and gids in hp-ux what are the rannges for the valid uids . How to check what are the used uids in Hp-ux . Thanks Narendra babu C (7 Replies)
Discussion started by: naren_chella
7 Replies

4. AIX

UIDs being overwritten immediately

We have a problem where we delete a user and their associated UID gets dumped back in the UID pool. The if we immediately create a another (new) user, AIX reuses the last UID, the one that was just released. This is causing a problem when reports are being generated because the new users name is... (2 Replies)
Discussion started by: xsys2000
2 Replies

5. Post Here to Contact Site Administrators and Moderators

What is meant by the words under usernames?

Under all users, there are some keynames. Some are obvious, like Moderator and Registered User. I have seen others too. What do they mean or signify?;) (2 Replies)
Discussion started by: joeyg
2 Replies

6. UNIX for Advanced & Expert Users

Usernames across Applications

Hello everyone, I was just wondering if there was a way to make it so that usernames could be used across applications. For instance, I have a server that has a bunch of users. I want these users to have ways of accessing my database as well as a variety of other programs, but I don't want them... (2 Replies)
Discussion started by: gonzofish
2 Replies

7. UNIX for Advanced & Expert Users

keep UIDs/GIDs consistent

Hi, What is the best ways to keep UIDs and GIDs consistent across unix and linux server. my company have a servers running on hpux, linux, aix and many of them have veritas cluster and hacmp running, many time user account have been created only on one of the cluster node and not the others... (4 Replies)
Discussion started by: robertngo
4 Replies

8. UNIX for Advanced & Expert Users

Usernames in Sudoers have #

We have users that have a # in their username. Sudo is working on some servers and not others. I have narrowed it down to the # in their username. Any suggestions or ideas why it is working on 1 server but not another. Server not working is - Solaris 10 patch level 138888-01 Server working is ... (1 Reply)
Discussion started by: Gibby13
1 Replies

9. Solaris

UIDs in /etc/passwd file

Hi all, I am bit confused about UIDs on my server where LDAP athentication happens. UIDs are generally in the range of 0-65534 for any Solaris OS version(correct if i am wrong). My server is running on Solaris 9. Below are user accounts available on my server. ... (10 Replies)
Discussion started by: vvpotugunta
10 Replies

10. Red Hat

pam_krb5 UID mapping (clashing UIDs)

Hi, I'm considering implementing pam_krb5 on RHEL 5.5 and Solaris 10, and I'm in an environment that has a number of legacy NIS domains. They've all been migrated into Active Directory, RFC2307, with the NIS maps that differed in each domain kept within its own container. However, users and... (0 Replies)
Discussion started by: cambridge
0 Replies
regex(1F)                                                          FMLI Commands                                                         regex(1F)

NAME
regex - match patterns against a string SYNOPSIS
regex [-e] [ -v "string"] [ pattern template] ... pattern [template] DESCRIPTION
The regex command takes a string from the standard input, and a list of pattern / template pairs, and runs regex() to compare the string against each pattern until there is a match. When a match occurs, regex writes the corresponding template to the standard output and returns TRUE. The last (or only) pattern does not need a template. If that is the pattern that matches the string, the function simply returns TRUE. If no match is found, regex returns FALSE. The argument pattern is a regular expression of the form described in regex(). In most cases, pattern should be enclosed in single quotes to turn off special meanings of characters. Note that only the final pattern in the list may lack a template. The argument template may contain the strings $m0 through $m9, which will be expanded to the part of pattern enclosed in ( ... )$0 through ( ... )$9 constructs (see examples below). Note that if you use this feature, you must be sure to enclose template in single quotes so that FMLI does not expand $m0 through $m9 at parse time. This feature gives regex much of the power of cut(1), paste(1), and grep(1), and some of the capabilities of sed(1). If there is no template, the default is $m0$m1$m2$m3$m4$m5$m6$m7$m8$m9. OPTIONS
The following options are supported: -e Evaluates the corresponding template and writes the result to the standard output. -v "string" Uses string instead of the standard input to match against patterns. EXAMPLES
Example 1: Cutting letters out of a string To cut the 4th through 8th letters out of a string (this example will output strin and return TRUE): `regex -v "my string is nice" '^.{3}(.{5})$0' '$m0'` Example 2: Validating input in a form In a form, to validate input to field 5 as an integer: valid=`regex -v "$F5" '^[0-9]+$'` Example 3: Translating an environment variable in a form In a form, to translate an environment variable which contains one of the numbers 1, 2, 3, 4, 5 to the letters a, b, c, d, e: value=`regex -v "$VAR1" 1 a 2 b 3 c 4 d 5 e '.*' 'Error'` Note the use of the pattern '.*' to mean "anything else". Example 4: Using backquoted expressions In the example below, all three lines constitute a single backquoted expression. This expression, by itself, could be put in a menu defini- tion file. Since backquoted expressions are expanded as they are parsed, and output from a backquoted expression (the cat command, in this example) becomes part of the definition file being parsed, this expression would read /etc/passwd and make a dynamic menu of all the login ids on the system. `cat /etc/passwd | regex '^([^:]*)$0.*$' ' name=$m0 action=`message "$m0 is a user"`'` DIAGNOSTICS
If none of the patterns match, regex returns FALSE, otherwise TRUE. NOTES
Patterns and templates must often be enclosed in single quotes to turn off the special meanings of characters. Especially if you use the $m0 through $m9 variables in the template, since FMLI will expand the variables (usually to "") before regex even sees them. Single characters in character classes (inside []) must be listed before character ranges, otherwise they will not be recognized. For exam- ple, [a-zA-Z_/] will not find underscores (_) or slashes (/), but [_/a-zA-Z] will. The regular expressions accepted by regcmp differ slightly from other utilities (that is, sed, grep, awk, ed, and so forth). regex with the -e option forces subsequent commands to be ignored. In other words, if a backquoted statement appears as follows: `regex -e ...; command1; command2` command1 and command2 would never be executed. However, dividing the expression into two: `regex -e ...``command1; command2` would yield the desired result. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
awk(1), cut(1), grep(1), paste(1), sed(1), regcmp(3C), attributes(5) SunOS 5.10 12 Jul 1999 regex(1F)
All times are GMT -4. The time now is 12:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy