Jul 29, 2004 #1 TheDash MIS Joined Mar 25, 2004 Messages 171 Location US Hi, Is there a way to sed 's/ */ /g' for NF>4? All other fields remain same. Only fields 5 and greater are applied.
Hi, Is there a way to sed 's/ */ /g' for NF>4? All other fields remain same. Only fields 5 and greater are applied.
Jul 29, 2004 #2 PHV MIS Joined Nov 8, 2002 Messages 53,708 Location FR The awk way: awk '{for(i=5;i<=NF;++i)gsub(/ */," ",$i;print}' /path/to/input Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244 Upvote 0 Downvote
The awk way: awk '{for(i=5;i<=NF;++i)gsub(/ */," ",$i;print}' /path/to/input Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
Jul 29, 2004 Thread starter #3 TheDash MIS Joined Mar 25, 2004 Messages 171 Location US Code: awk '{for(i=5;i<=NF;++i)gsub(/ */," ",$i;print}' /path/to/input I put the missing ) here Code: awk '{for(i=5;i<=NF;++i)gsub(/ */," ",$i);print}' /path/to/input but it hangs Upvote 0 Downvote
Code: awk '{for(i=5;i<=NF;++i)gsub(/ */," ",$i;print}' /path/to/input I put the missing ) here Code: awk '{for(i=5;i<=NF;++i)gsub(/ */," ",$i);print}' /path/to/input but it hangs
Jul 29, 2004 #4 PHV MIS Joined Nov 8, 2002 Messages 53,708 Location FR And this ? awk '{for(i=5;i<=NF;++i)gsub(/ /," ",$i);print}' /path/to/input Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244 Upvote 0 Downvote
And this ? awk '{for(i=5;i<=NF;++i)gsub(/ /," ",$i);print}' /path/to/input Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
Jul 29, 2004 #5 iribach Technical User Joined Oct 12, 2002 Messages 211 Location CH not easy in sed, and awk compress the IFS ... if you can get|put an other IFS as ' ' you get a chance to do it. Upvote 0 Downvote
not easy in sed, and awk compress the IFS ... if you can get|put an other IFS as ' ' you get a chance to do it.