Copying x words from end of line to specific location in same line

Hello all
i know it is pretty hard one but you will manage it all

after noticing and calculating i find a rhythm for the file i want to edit
to copy the last 12 characters in line but the problem is to add after first 25 characters in same line

in other way too copy the last 12 characters in line and add them after /up/upfiles/ in same line

the problem i faced mainly how to copy word from end of the line to the beginning of line

i am still newbie by the way

here is the input:

Redirect 303 /up/upfiles/  /http://img189.imageshack.us/img189/3162/3jy83426.jpg
Redirect 303 /up/upfiles/  /http://img696.imageshack.us/img696/5284/3kr88432.jpg
Redirect 303 /up/upfiles/  /http://img411.imageshack.us/img411/918/3nw51001.jpg

i want the output to be like this :

Redirect 303 /up/upfiles/3jy83426.jpg  /http://img189.imageshack.us/img189/3162/3jy83426.jpg
Redirect 303 /up/upfiles/3kr88432.jpg  /http://img696.imageshack.us/img696/5284/3kr88432.jpg
Redirect 303 /up/upfiles/3nw51001.jpg  /http://img411.imageshack.us/img411/918/3nw51001.jpg

Thanks in advance

Try this:

awk '{n=split($NF,a,"/");$3=$3 a[n]}1' file
sed 's|\(  *[^ ]*/\)\([^/]*\)$|\2\1\2|' infile

use below:-

nawk '{match($NF,/[^\/]*.jpg/);$3=$3substr($NF,RSTART)}1' file.txt

:cool::cool::cool:

Or:

awk -F/ '$4=$NF$4' OFS=/ infile

hello
i will try now all of them and reply to each one
thanks for you all

---------- Post updated at 04:42 PM ---------- Previous update was at 04:32 PM ----------

Worked really really fine

Worked really really fine

Worked really really fine but i can't use it because the file is about 4 thousands lines and not all .jpg

Worked really really fine

i really appreciate your help guys with me
and i really want to learn this language
what is the best way to learn it ?

use modified code below:-

nawk '{match($NF,/[^\/]*$/) ; $3=$3substr($NF,RSTART)}1' infile.txt

;);):wink:

Visit www.unix.com more frequently.

Hello
now i had little problem

the input is :

Redirect 303 /up/upfiles/zst29595.jpg /http://img682.imageshack.us/img682/4786/zst29595.jpg
Redirect 303 /up/upfiles/ztj10579.jpg /http://img404.imageshack.us/img404/9339/ztj10579.jpg

notice the / before http

the output should be :

Redirect 303 /up/upfiles/zst29595.jpg http://img682.imageshack.us/img682/4786/zst29595.jpg
Redirect 303 /up/upfiles/ztj10579.jpg http://img404.imageshack.us/img404/9339/ztj10579.jpg

Thanks in advance

$ 
$ cat f4
Redirect 303 /up/upfiles/zst29595.jpg /http://img682.imageshack.us/img682/4786/zst29595.jpg
Redirect 303 /up/upfiles/ztj10579.jpg /http://img404.imageshack.us/img404/9339/ztj10579.jpg
$ 
$ # Using sed
$ sed 's/\/http/http/' f4
Redirect 303 /up/upfiles/zst29595.jpg http://img682.imageshack.us/img682/4786/zst29595.jpg
Redirect 303 /up/upfiles/ztj10579.jpg http://img404.imageshack.us/img404/9339/ztj10579.jpg
$ 
$ # Using awk
$ awk 'sub("/http","http")' f4
Redirect 303 /up/upfiles/zst29595.jpg http://img682.imageshack.us/img682/4786/zst29595.jpg
Redirect 303 /up/upfiles/ztj10579.jpg http://img404.imageshack.us/img404/9339/ztj10579.jpg
$ 
$ # Using Perl
$ perl -lne 's/\/http/http/; print' f4
Redirect 303 /up/upfiles/zst29595.jpg http://img682.imageshack.us/img682/4786/zst29595.jpg
Redirect 303 /up/upfiles/ztj10579.jpg http://img404.imageshack.us/img404/9339/ztj10579.jpg
$ 
$ # Using Ruby
$ ruby -pe 'sub("/http","http")' f4
Redirect 303 /up/upfiles/zst29595.jpg http://img682.imageshack.us/img682/4786/zst29595.jpg
Redirect 303 /up/upfiles/ztj10579.jpg http://img404.imageshack.us/img404/9339/ztj10579.jpg
$ 
$ 

tyler_durden

Hello
Extremely wonderful tyler
you made me really speechless
thanks a loot