User ID Counting
In this challenge, you will write a Bash script to fetch user-ids from the /etc/passwd
file, display only usernames within a specific range based on command-line arguments, and count the number of users within the specified range.
Tasks
You need to complete the following task:
- Fetch user-ids from the
/etc/passwd
file.
- Display only usernames within a specific range based on command-line arguments.
- Count the number of users within the specified range.
Requirements
You must meet the following requirements:
- The script should be named
userId.sh
.
- Working directory for the script should be
~/project
.
- Use commands
df
, cut
, and tr
.
- Utilize loops and arrays in the Bash script.
Example
labex:project/ $ bash userId.sh
[OUTPUT] UID AND USERNAME [OUTPUT]
5000: labex
999: mongodb
[OUTPUT] Total count of User-id Between 500 to 10000 is "2" [OUTPUT]