我如何在bash输出中创建一个表,显示关于特定用户的每一项?
我有简单的bash脚本我如何在bash输出中创建一个表,显示关于特定用户的每一项?,bash,ubuntu,Bash,Ubuntu,我有简单的bash脚本 #!/bin/bash grep home /etc/passwd | grep $1 显示有关用户的信息, 输出示例: Vladislav:x:1000:1000:Vladislav,,,:/home/vladislav:/bin/bash 有没有可能让它看起来像?我的意思是-有两列和 行之间的简单分隔符如果您只需要列,则可以将其格式化为: grep home /etc/passwd | grep $1 | sed 's/:/ /g' | awk '{NAME=
#!/bin/bash
grep home /etc/passwd | grep $1
显示有关用户的信息,
输出示例:
Vladislav:x:1000:1000:Vladislav,,,:/home/vladislav:/bin/bash
有没有可能让它看起来像?我的意思是-有两列和
行之间的简单分隔符如果您只需要列,则可以将其格式化为:
grep home /etc/passwd | grep $1 | sed 's/:/ /g' | awk '{NAME=$1;ENC=$2;AMT=3;MIN=$4;$1=$2=$3=$4="";print "name\t"NAME"\nEncrypted password\t"ENC"\nAmount of days\t"AMT"\nMinimum count of days\t"MIN"\nOther item description\t"$0}'
这将获取原始输出,用文本空间替换:
,然后将其输入awk并格式化“表”
我从示例输入字符串中获得的输出是:
name Vladislav
Encrypted password x
Amount of days 3
Minimum count of days 1000
Other item description Vladislav,,, /home/vladislav /bin/bash
你也想要屏幕截图上的拼写错误吗?你想买盒子吗?您希望使用可变宽度字体吗?