Results 1 to 5 of 5
I have a line
this is a universe this is a hello world
want to print 2 field to last field, so doing following
{for(i=5;i<=NF;i++) printf $i}
but I am ...
- 04-11-2008 #1Just Joined!
- Join Date
- Apr 2008
- Posts
- 19
How to give space using printf
I have a line
this is a universe this is a hello world
want to print 2 field to last field, so doing following
{for(i=5;i<=NF;i++) printf $i}
but I am getting output like this (withought space between)
isauniversethisisahelloworld
please suggest how can get the space here, like
is a universe this is a hello world
- 04-11-2008 #2Linux Engineer
- Join Date
- Nov 2004
- Location
- Ft. Polk, LA
- Posts
- 796
What language are you trying to do this in?
- 04-11-2008 #3Just Joined!
- Join Date
- Apr 2008
- Posts
- 19
Shell..
sorry i forgot to mention, correct syntax
awk '{for(i=5;i<=NF;i++) printf $i}'
- 04-12-2008 #4Linux Engineer
- Join Date
- Nov 2004
- Location
- Ft. Polk, LA
- Posts
- 796
In that case, there's no need to do all that work to accomplish what you're trying to do. Here's a simpler solution:
I highly recommend you check out http://tldp.org/LDP/abs/htmlCode:string="this is a universe this is a hello world" echo ${string:5}
- 04-13-2008 #5Linux User
- Join Date
- Aug 2006
- Posts
- 458


Reply With Quote
