简体   繁体   中英

Print space if the rows are the same in awk

I would like to print space or dot if my rows are the same.

See the example:

INPUT:

row1 xx yy zz
row1 xx yy zz
row1 xx yy zz
row2 aa bb cc
row2 aa bb cc
row3 gg hh oo

OUTPUT:

row1 xx yy zz
     xx yy zz
     xx yy zz
row2 aa bb cc
     aa bb cc 
row3 gg hh oo

Is there any easy way to print just space?

Thank you for any help.

$ awk '{c=$1} c==p{gsub(/./," ",$1)} {p=c} 1' file
row1 xx yy zz
     xx yy zz
     xx yy zz
row2 aa bb cc
     aa bb cc
row3 gg hh oo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM