Domanda

is there any way in linux command ,when i give the list text aaaaaaaaaa.htm 4 bbbbbbbbbb.htm 5 .... it will give me the result aaaaaaaaaa_2.htm aaaaaaaaaa_3.htm aaaaaaaaaa_4.htm bbbbbbbbbb_2.htm bbbbbbbbbb_3.htm bbbbbbbbbb_4.htm bbbbbbbbbb_5.htm ... Thanks much for any helps !

È stato utile?

Soluzione

Like this?

cat list.txt 
aaaaaaaaaa.htm 4
bbbbbbbbbb.htm 5
awk '{gsub(/.htm/,"",$1);for (i = 2; i<=$2;i++){printf "%s_%s.htm\n",$1,i}}' list.txt 
aaaaaaaaaa_2.htm
aaaaaaaaaa_3.htm
aaaaaaaaaa_4.htm
bbbbbbbbbb_2.htm
bbbbbbbbbb_3.htm
bbbbbbbbbb_4.htm
bbbbbbbbbb_5.htm
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top