quick awk-to-sed question

Code junkies hangout here

Moderators: ChriThor, LXF moderators

quick awk-to-sed question

Postby silly_xp_user » Sat May 22, 2010 5:56 pm

Hello, can someone please assist.
I would like to know how the following might be done in sed.
I have read sed1liners and various other sed faqs but cannot quite work this one out.

Thanks for any constructive help given.

Code: Select all
#Align second field of each line offset 15.
#How would you do this with sed?

cat << EOF | awk '{ printf "%-15s ",$1; for(i=2;i<=NF;i++) printf "%s ",$i ; print ""}'
1 one
10 ten
300 three hundred
1000 one thousand
90042 ninety thousand and forty two

#- gives this output without the hashes (#).
#1               one
#10              ten
#300             three hundred
#1000            one thousand
#90042           ninety thousand and forty two
User avatar
Posts: 11
Joined: Sat Oct 22, 2005 3:55 pm

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests