Jul 29, 2004 #1 TheDash MIS Mar 25, 2004 171 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 Nov 8, 2002 53,708 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 Mar 25, 2004 171 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 Nov 8, 2002 53,708 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 Oct 12, 2002 211 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.