|
|
|
|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | 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. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
Need to find Unique not used Number
Wrote a script to create a hidden account in OS X. It works perfect but I need to check if the UID is already in use before I tried to create the account. Code:
dscl . list /Users UniqueID | awk '{print $2}' | while read UIDS
do
if [ "$UIDS" == "$2" ]; then
echo "UID Is Already in USE"
i=`expr "$2" - 1`
echo "$i"
exit 0This helps but if the selected UID minus (one) is in use the script proceeds. I need a loop and decrement the number until it finds one that is not in use. |
| Sponsored Links | ||
|
|
|
|||
|
use a while loop, something like this
dscl . list /Users UniqueID | awk '{print $2}' | while read UIDS do while ( "$UIDS" == "$2") do echo "UID Is Already in USE" i=`expr "$2" - 1` done echo "$i" done cheers, Devaraj Takhellambam |
|
|||
|
I think it was already correct. Still the same issue. Would you like me to post my entire script? Are you on a MAC?
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| display unique number | malaysoul | Shell Programming and Scripting | 1 | 06-02-2008 09:14 AM |
| Need to find only unique values for a given tag across the files | sudheshnaiyer | UNIX for Dummies Questions & Answers | 8 | 09-03-2007 01:53 AM |
| unique number for a date | madmat | Shell Programming and Scripting | 4 | 11-30-2006 12:35 PM |
| Directory Inode Number Not Unique | nj302 | UNIX for Dummies Questions & Answers | 9 | 05-22-2005 12:34 PM |
| Script to count unique number of user loged in | elchalateco | Shell Programming and Scripting | 1 | 09-30-2002 12:32 PM |