Jul 23, 2002 #1 630111 MIS Joined Oct 30, 2001 Messages 127 Location US When I run nsrjb | grep [-*] it outputs the following result... 19: 38: 59: 64: 91: 114: What awk statement do I use to get rid of the : at the end of each line? Thanks! 630111
When I run nsrjb | grep [-*] it outputs the following result... 19: 38: 59: 64: 91: 114: What awk statement do I use to get rid of the : at the end of each line? Thanks! 630111
Jul 23, 2002 1 #2 vgersh99 Programmer Joined Jul 27, 2000 Messages 2,146 Location US nawk -F ":" '{print $1}' d.txt sed -e 's/\(.*\):[ ]*$/\1/g' d.txt vlad +---------------------------+ |#include<disclaimer.h> | +---------------------------+ Upvote 0 Downvote
nawk -F ":" '{print $1}' d.txt sed -e 's/\(.*\):[ ]*$/\1/g' d.txt vlad +---------------------------+ |#include<disclaimer.h> | +---------------------------+
Jul 24, 2002 #3 dchoulette Programmer Joined Jun 25, 2002 Messages 245 Location FR Code: nawk -F ":" '{print $1}' d.txt work if there is only one ':' character in the line as in the given data sample. In this case, you could also use the cheaper command Code: cut -d: -f1 < d.txt The sed equivalent of the previous commands is Code: sed -e 's/:.*//' d.txt To suppress only the ':' at the end of the line even if there are other ':' in the line: Code: sed -e 's/:$//' d.txt Upvote 0 Downvote
Code: nawk -F ":" '{print $1}' d.txt work if there is only one ':' character in the line as in the given data sample. In this case, you could also use the cheaper command Code: cut -d: -f1 < d.txt The sed equivalent of the previous commands is Code: sed -e 's/:.*//' d.txt To suppress only the ':' at the end of the line even if there are other ':' in the line: Code: sed -e 's/:$//' d.txt