If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
I have a situation now where the data is in the fomat as below: i just need to remove all the text in one field that appears after the / but maintain all the other text in the row.
2004032508 Rseln-NwMuthig/ain16x|8+2Mps/2b#1 communic. major
2004032508 Milani-aka/Min8x2|8+2bps/Frae#1 equp std
2004032508 Milmni-aka/Min8x2|8+2Mbps/2b#2 power. major
2004032508 Milimni-aka/ain8x2|8+2bps/2b#1 communic. minor
2004032508 Milini-Naa/ain8x2|8+2bps environm stable
2004032508 KA-tirier/Mai16x2|8+2bps/2b#1 communic. major
What i need to my output is:
2004032508 Rseln-NwMuthig communic. major
2004032508 Milani-aka equp std
2004032508 Milmni-aka power. major
2004032508 Milimni-aka communic. minor
2004032508 Milini-Naa environm stable
2004032508 KA-tirier communic. major
{ ... } : executed for each record
sub(/\/.*/,"",$2) : substitute in field 2, '/' and all trailing characters by nothing.
print : print the modified record
Originally posted by aigles
You can use awk to do that :
Code:
awk '{sub(/\/.*/,"",$2) ; print}' input_file
{ ... } : executed for each record
sub(/\/.*/,"",$2) : substitute in field 2, '/' and all trailing characters by nothing.
print : print the modified record
Hello Aigles,
Thanks for the code but unfortunately am getting a syntax error on execution of the script as below:
awk '{sub(/\/.*/,"",$2) ; print}' trans >trans.txt