Article 5NY17 grep -v "$(whoami)" not working

grep -v "$(whoami)" not working

by
crusader7
from LinuxQuestions.org on (#5NY17)
Hello LQ!!

I have tried many variations to remove myself from the following script, but unsuccessful.
I tried different variations of the following, but it still has myself included in the user list:
Quote:
grep -v "$(whoami)"
or
userType="$(whoami)"
users=$(cat /etc/passwd | grep bash | grep -v root | grep -v "$userType" | awk -F: '{ print $1}')
I would appreciate your help on how to omit myself from the list of users?
Here is my script in total.

Code:#!/bin/bash

# This script changes the password age of each user except for root and the current user.

# Todays date used to modify chage
date=$(date '+%Y-%m-%d')

users=$(cat /etc/passwd | grep bash | grep -v root | grep -v "$(whoami)" | awk -F: '{ print $1}')

for value in $users
do
echo $value
sudo chage -d $date -M 90 -m 10 -I 30 -W 10 -E 2022-01-01 $value
echo "....."
echo ""
doneThanks in advance :)latest?d=yIl2AUoC8zA latest?i=vp7DRCaPRo0:BvGoGQ8DkYg:F7zBnMy latest?i=vp7DRCaPRo0:BvGoGQ8DkYg:V_sGLiP latest?d=qj6IDK7rITs latest?i=vp7DRCaPRo0:BvGoGQ8DkYg:gIN9vFwvp7DRCaPRo0
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments