Regular expression – AWK for separating words by underscore

I use awk very badly, but I know it is very useful for contingency operations.

I have a form file:

JohnSmith_name 3.4 
KellySears_name 5.7
RonaldBay_name 1.2
RayShendor_name 2.8

I want to read the file and basically delete it from the real name_ name the label and print the line. How can I do this with awk?

Thank you!

In this case, you can use sed more easily than awk, I think:

$sed s/_name// file
JohnSmith 3.4
KellySears 5.7
RonaldBay 1.2
RayShendor 2.8

I use awk very badly, but I know it is very useful for strain manipulation.

I have a table file:

JohnSmith_name 3.4 
KellySears_name 5.7
RonaldBay_name 1.2
RayShendor_name 2.8

I want to read the file and basically delete it from the real name _name label and print the line. How can I do this with awk?

Thank you!

In this case, you can use sed more easily than awk, I think:

$sed s/_name// file
JohnSmith 3.4
KellySears 5.7
RonaldBay 1.2
RayShendor 2.8

Leave a Comment

Your email address will not be published.