Appending the first word of each line to the end of each line

Hi Experts,

Am relatively new to shell programming so would appreciate some help in this regard.
I am looking at reading from a file, line by line, picking the first word of each line and appending it to the end of the line.

Any suggestions?

INPUT FILE -

3735051 : 10gdb_nonfa_noldapsync_ps2 : http://dte.com/dte30/faces/monitorPage/jobId=
3735052 : 11gdb_nonfa_noldapsync_ps2 : http://dte.com/dte30/faces/monitorPage/jobId=
3735053 : 112gdb_nonfa_noldapsync_ps2 : http://dte.com/dte30/faces/monitorPage/jobId=

This is how id like my output file to look like -

3735051 : 10gdb_nonfa_noldapsync_ps2 : http://dte.com/dte30/faces/monitorPage/jobId=3735051
3735052 : 11gdb_nonfa_noldapsync_ps2 : http://dte.com/dte30/faces/monitorPage/jobId=3735052
3735053 : 112gdb_nonfa_noldapsync_ps2 : http://dte.com/dte30/faces/monitorPage/jobId=3735053

TIA

Use code tags next time please. If not sure what I am talking about, leave me a note.

To your problem:

awk '{print $0$1}' infile

This works well, thanks !!
My bad about the code tags, will keep in mind in future !

And yet another -

perl -lane 'print $_,$F[0]' yourfile

tyler_durden

... and another :slight_smile:

sed 's/^\([^ ]*\).*/&\1/' file

Cheers,
Alister

awk '$0=$0$1' urfile
sed 's/\(.[^:]*\)\(.*\)/\1\2\1/' file
awk 'BEGIN{FS=OFS=":"}
        {
        $NF=sprintf("%s%s",$NF,$1)
        print
        }'