Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
PacketMan

Get a number from grep

nevermind, I figured it out!

jk

what I finally did is:

uid=`grep -oE 'root:[0-9a-zA-Z]+:[0-9+:[0-9]+' | cut --delimiter=: -f 3`

 

Recommended Posts

Posted · Original PosterOP

Hey, so I've been wondering...

If I wanted to get the UID and the GID from a user, how would I do it?

I've tried

#!/bin/bash
uid=`grep -oE 'root:[0-9a-zA-Z]+:[0-9]+:[0-9]+' /etc/passwd`
echo $uid

But I only get "root:x:0:0"

How can I get just the UID and the GID of the account?

Link to post
Share on other sites
Posted · Original PosterOP · Best Answer

nevermind, I figured it out!

jk

what I finally did is:

uid=`grep -oE 'root:[0-9a-zA-Z]+:[0-9+:[0-9]+' | cut --delimiter=: -f 3`

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×