![]() |
passing a list of arguments to a command
Hello,
I would like to use a "chage" command to set the password expiry date for all users. The problem is that the function takes only the single username as the argument: chage -E date user So, I'd like to combine it with "ls -1 /home" which gives me the list of usernames one in each row. Is that possble somehow? Thank you. |
You could do this with a shell script:
Code:
#!/bin/bashYou can use cat /etc/passwd | cut -d':' -f1 to get a more reliable list of all the users, but this appoach will pick up all the system user accounts. |
/etc/passwd is a much nicer route, and to avoid system accounts, i'd recommend filtering the uid or gid. depending on how your users are organised, if you have a fixed user group:
Code:
for i in $(cat /etc/passwd | cut -f 1,4 -d\:) |
| All times are GMT -5. The time now is 03:11 PM. |