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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prepend and Append to a field 1

Status
Not open for further replies.

mrimagepueblo

Programmer
Dec 15, 2003
52
0
0
US
Using /bin/sh shell script. I have to pull fields from a bigger file, no problem there, I'm just clueless on adding something to the beginning and the end of a field.

I have a pipe delimited file as such: I'll only use one line for the example: 12345 will always match, as I'm just duplicating whatever is in field 1 to the fourth field.

example:
12345|JF1SG65683H725202|data|12345|data|data|

What I want to be able to do is prepend and append two variables to the fourth field. It will always be
to the front and .jpg to the end.

end result:
12345|JF1SG65683H725202|data|
Any help would be appreciated.
 
Try..
Code:
awk 'BEGIN {
             FS = OFS = "|"
     }
     {
             $4 = "[URL unfurl="true"]http://www.domain.com/images/"[/URL] $4 ".jpg"
             print $0
     }
     ' file1 > file2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top