I am trying to find the UID in a certain range and only showing those UIDs with their name. The range is determined by two arguments I enter in my command line. However, I don't receive the right answer in the code I am using now. Below, the first command shows running the code I am using now. In the second command, you will see the answer that I should have.
$ ./UserID 10 100
root:0
$ ./UserID 10 100
operator: 11
games: 12
ftp: 14
dbus: 81
apache: 48
tss:59
avahi: 70
грс:32
rpcuser: 29
gdm: 42
sshd: 74
tcpdump: 72
#! /bin/bash
min=$1
max=$2
awk -F: '($3>=min) && ($3<=max ) {printf "%s:%s\n",$1,$3}' /etc/passwd
min
ormax
variables anywhere after defining them. – muru Nov 15 '22 at 09:24awk
cannot see shell variables -- they use different name spaces. Pass the shell values into awk like:awk -v min="${min}" -v max="${max}" -F: ....
. Your image clips off the command -- I assume you are reading /etc/passwd. Don't post images -- please add the data or code as a code block. – Paul_Pedant Nov 15 '22 at 09:55