any good idea on this?

txt file like this,

1 2 3 4456
a bb c d 3 f e
1 k 32 d m f e
123 m 2 k

every line contains 3 or more columns, all the columns are separated by space, and every column includes 1 to 3 character.

what I wanna do is deleting the first three columns, and keep the rest no matter how long the rest will be, is there a fast way to do this?

try this

awk ' 
{ 
for ( i = 4 ; i < NF ; ++i ) 
        printf( "%s " , $i );
printf( "%s\n" , $NF )
}' file

hmm, thank you anbu23,

I am just wondering if there is a magic method to do this....:slight_smile:

Use cut:

cut -d" " -f 4- filename

you can also use cut to do this

cut -d" " -f4- 

amazing!

Glenn Arndt and anbu23, you guys are really smart!

so the "-" after 4 means "to the end"? I check the manpage of cut, did not find answer for this at first glance.

Yes. Similarly, you can also do -4 to get all the fields up to and including the 4th.

thanks again, Glenn, this tip is really great!

I bet I will use it for thousands of times in the future.