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

Enclose data with unique text

Status
Not open for further replies.

jestrada101

Technical User
Mar 28, 2003
332
Example: my data file

John Doe
Billy Bob
Jane Doe


I then want my script to enclose data like this.

**************************
*John Doe *
*Billy Bob *
*Jane Doe *
**************************

Thanks for any guidance.

JE
 
Use th following awk program
Code:
# ------   je.awk   ------
BEGIN {print "**************************"}
{print "*" $0 substr("                        ",1,24-length) "*"}
END {print "**************************"}
Run it by entering

awk -f je.awk input.dat

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
Cool... this is what I want it to do... is there a way to include this "awk" function into a shell script?
 
Enclosing it in single quotes works in most places on most systems

awk 'BEGIN {print "**************************"}
{print "*" $0 substr(" ",1,24-length) "*"}
END {print "**************************"}' input.dat

CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top