Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

quick awk-to-sed question

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
silly_xp_user



Joined: Sat Oct 22, 2005 4:55 pm
Posts: 11

PostPosted: Sat May 22, 2010 6:56 pm    Post subject: quick awk-to-sed question Reply with quote

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.

Hal
Code:
#!/bin/bash
#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
EOF

#- gives this output without the hashes (#).
#1               one
#10              ten
#300             three hundred
#1000            one thousand
#90042           ninety thousand and forty two
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast