Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我如何在bash输出中创建一个表,显示关于特定用户的每一项?_Bash_Ubuntu - Fatal编程技术网

我如何在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=

我有简单的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=$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

你也想要屏幕截图上的拼写错误吗?你想买盒子吗?您希望使用可变宽度字体吗?