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:
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 :)
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}') |
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 :)