4
votes
Accepted
Remove duplicates by adding numerical suffix
awk can take arbitrary array indices - even a whole record ("line").
Make a regex match for tag: and start the counter, but correct by one due to the first match
awk '$0 ~ /^tag:/ { n[$0]++?$...
3
votes
Remove duplicates by adding numerical suffix
Here we go, exactly as required:
awk '
NR==FNR{
if (/^tag:/) {
a[$1]++
}
next
}
{
c=--a[$1]
if (c>0) {
printf "%s-%....
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
python × 2278linux × 323
bash × 227
ubuntu × 194
debian × 146
python3 × 146
pip × 141
shell-script × 137
centos × 116
shell × 109
software-installation × 84
awk × 74
scripting × 74
cron × 73
rhel × 67
text-processing × 66
systemd × 59
apt × 59
perl × 57
package-management × 56
sed × 55
arch-linux × 55
yum × 54
raspberry-pi × 47
command-line × 45