linux - 使用 chage 和 grep 命令使密码过期
问题描述
我的 chage -l $person 命令可以完美地将所有密码信息显示到屏幕上,但我需要使用 grep 和 cut 命令来获取密码到期日期。我不能使用 awk 命令,因为我们还没有在课堂上学习它,所以我坚持使用 cut 和 grep 来获取我需要的行。
Last password change : Feb 19, 2020
Password expires : Jun 18, 2020
Password inactive : Jun 28, 2020
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 120
Number of days of warning before password expires : 10
我试过了
chage -l "$person" | grep 'Password expires' | cut -d ':'
这是怎么回事?
解决方案
您缺少告诉它要打印哪一列的-f
选项。cut
chage -l "$person" | grep 'Password expires' | cut -d ':' -f 2
推荐阅读
- javascript - 在屏幕中央对齐一列
- c# - 使用 JSON.net 序列化不带引号的 yyyyMMdd 格式日期
- python - Python导入csv并随机选择行并使用其他随机值打印
- javascript - 材质 UI 表格单元格相同的固定宽度
- javascript - 为什么 888888888888888888888 在 JavaScript 中等于 888888888888888900000
- python - Python:RecursionError:调用 Python 对象时超出最大递归深度
- java - 如果初始 @then 自动化失败,黄瓜执行将停止执行
- google-maps - 如何使用谷歌地图 api 和颤振制作折线
- c# - .Net Core 3.1 的 HttpClient 调用失败
- python - keras 日志中缺少 val_loss,但在 epoch 结束时正确打印