bash スクリプト: 出力変更 uniq -c

bash スクリプト: 出力変更 uniq -c

uniq -cの出力を変更する必要があります:(はい)

92 root
80 user

存在する

root 92
user 80

awk forceを使用せずにどうすればよいですか?

ベストアンサー1

ここでGNUを使うことができますsed

... | sed -E 's/(\S*) (\S*)/\2 \1/'

またはPOSIXly、

... | sed 's/\([^ ]*\) \(.*\)/\2 \1/'

おすすめ記事