Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

re-position string in a line at different position

Status
Not open for further replies.

MGoel

Programmer
Jan 26, 2002
17
US
Hello All,

I have a data file and I want to reposition some of the data in a line at different position on the same line.

e.g.

552404: MF 23456 XXXXX
to
552404: MF 23456 XXXXX

How can i do that.

Thanks in advance

Manoj
 
the only diff. I see is the width of some of the fields. You might consider using printf's field width parameters. vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
...So, assuming FS = ' ' (the default)
awk '{
printf(&quot;%s,%6s,%8s,%22s&quot;,$1,$2,$3,substr($0,22,22))
}' datafile
HTH
;-) Dickie Bird
db@dickiebird.freeserve.co.uk
 
Ooops - screwed by commas again, They are superfluous in &quot;%s,%6s,%8s,%22s&quot; !!!
It should be :
printf(&quot;%s%6s%8s%22s&quot;,$1,$2,$3,substr($0,22,22))
;-)
Dickie Bird
db@dickiebird.freeserve.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top