Pregunta

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 !

¿Fue útil?

Solución

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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top