给出以下文件的内容:
alias command with whitespace-separated argument list anotheralias othercommand and its arguments
我怎么能打印像:
alias = command with whitespace-separated argument list anotheralias = othercommand and its arguments
目前我正在使用以下命令,但这是错误的。
cat aliases | awk '{printf "%20s = %s\n", $1, $0}'
答案 0 :(得分:3)
cat aliases | awk '{$1=sprintf("%20s =",$1);print}'
答案 1 :(得分:1)
cat aliases | awk '{ printf("%20s =", $1); $1=""; printf("%s\n", $0) }'
答案 2 :(得分:0)
sed 's/ /=/1' yourFile|awk -F= '{printf ("%20s = %s\n",$1,$2)}'
答案 3 :(得分:0)
只需使用shell:
while read line; do
set -- $line
cmd=$1
shift
printf "%20s = %s\n" "$cmd" "$*"
done < filename