How to extract text from STRING to end of line?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to extract text from STRING to end of line?
# 1  
Old 06-17-2013
How to extract text from STRING to end of line?

Hi

I have a very large data file with several hundred columns and millions of lines.

The important data is in the last set of columns with variable numbers of tab delimited fields in front of it on each line.

Im currently trying sed to get the data out - I want anything beetween :RES and the end of line in the example two lines below (lines begin with chr):

Currently Im trying variations on

sed -n '/RES/, /$/p' BIGFILE >sedout

which gets me the first set of info before :RES but not after

can anyone help - apologies for the inexperience

chr2 166746903 . CTAA CTAATATAA 999.0 mrd10;tdb0.05;mrd15;mrp0.05;bqb0.05 INDEL;DP=1647;VDB=0.0367;AF1=0.03161;AF2=0.08017,4.387e-06;LRT=4.35e-05;LRT2=0.000173;AC1=14;DP4=1300,129,22,0;MQ=35;FQ=999;PCHI2=0.0107;PC2=0,58;PV4=0.25,7.1e-06,0.43,1.7e-13;EFF=INTRON(MODIFIER||||TTC21B|retained_intron|CODING|ENST00000243344|),INTRON(MODIFIER||||TTC21B| retained_intron|CODING|ENST00000536175|);MPB=U;ABPA=22;ASTHMA=19 GT:PLSmilieP:SP:GQ:RES 0/0:0,81,255:27:0:93:0 0/0:0,24,153:8:0:36:0 0/0:0,93,238:31:0:99:0 0/1:14,0,135:7:0:4:0 0/0:0,6,64:2:0:18:0 0/0:0,63,245:21:0:75:0 0/0:0,15,140:5:0:27:0 0/0:0,3,35:1:0:15:-1 0/0:0,0,0:0:0:12:0 0/0:0,0,0:0:0:12:0 0/0:0,0,0:0:0:12:0 0/0:0,3,35:1:0:15:0 0/0:0,0,0:0:0:12:0 0/0:0,3,35:1:0:15:0 0/0:0,9,87:3:0:21:0 0/0:0,0,0:0:0:12:0 0/0:0,9,87:3:0:21:0 0/0:0,120,255:40:0:99:0 0/0:0,27,160:9:0:39:0 0/0:0,0,0:0:0:12:0 0/0:0,9,87:3:0:21:0 0/0:0,0,0:0:0:12:0 0/0:0,9,75:3:0:21:0 0/0:0,6,64:2:0:18:0 0/0:0,3,35:1:0:15:-1 0/0:0,87,255:29:0:99:-1 0/0:0,12,106:4:0:24:-1 0/0:0,12,101:4:0:24:0 0/1:14,0,117:7:0:4:0 0/0:0,6,60:2:0:18:0 0/0:0,27,185:9:0:39:0 0/0:0,9,87:3:0:21:0 0/0:0,3,35:1:0:15:-1 0/0:0,81,213:27:0:93:0 0/1:32,3,0:1:0:13:0 0/0:0,3,35:1:0:15:0 0/0:0,0,0:0:0:12:0 0/0:0,0,0:0:0:12:0 0/0:0,24,153:8:0:36:-1 0/0:0,39,228:13:0:51:-1 0/0:0,21,168:7:0:33:0 0/0:0,3,35:1:0:15:-1 0/0:0,0,0:0:0:12:0 0/0:0,3,35:1:0:15:0 0/0:0,15,140:5:0:27:0 0/0:0,0,0:0:0:12:-1 0/0:0,6,64:2:0:18:0 0/0:0,15,122:5:0:27:-1 0/0:0,12,106:4:0:24:-1 0/0:0,0,0:0:0:12:0 0/0:0,0,0:0:0:12:0 0/0:0,3,35:1:0:15:0 0/0:0,0,0:0:0:12:0 0/0:0,57,255:19:0:69:0 0/1:35,0,132:10:0:23:0 0/1:14,0,137:7:0:4:0 0/0:0,12,100:4:0:24:0 0/0:0,12,106:4:0:24:0 0/0:0,52,238:29:0:64:-1 0/0:0,72,239:24:0:84:0 0/0:0,60,255:20:0:72:0 0/0:0,21,168:7:0:33:0 0/0:0,55,255:30:0:67:0 0/0:0,42,177:14:0:54:0 0/0:0,39,255:13:0:51:0 0/0:0,3,35:1:0:15:0 0/0:0,181,255:60:0:99:0 0/0:0,18,169:6:0:30:-1 0/0:0,21,145:7:0:33:0 0/0:2,0,212:11:0:10:0 0/0:0,12,94:4:0:24:0 0/0:0,6,70:2:0:18:0 0/0:0,18,156:6:0:30:0 0/0:0,9,98:3:0:21:0 0/1:72,0,23:4:0:41:0 0/1:25,0,29:2:0:13:0 0/1:14,0,137:7:0:4:0 0/0:0,0,0:0:0:12:0 0/0:0,66,255:22:0:78:-1 0/0:0,18,135:6:0:30:0 0/0:0,6,64:2:0:18:0 0/0:0,6,64:2:0:18:0 0/0:0,132,255:44:0:99:0 0/0:8,0,125:8:0:5:-1 0/1:35,0,132:10:0:23:0 0/0:0,15,115:5:0:27:-1 0/0:0,6,70:2:0:18:-1 0/0:0,15,122:5:0:27:0 0/1:41,0,136:8:0:29:-1 0/0:0,6,64:2:0:18:0 0/1:26,0,55:3:0:14:-1 0/0:0,27,185:9:0:39:0 0/0:2,0,139:11:0:10:0 0/0:0,30,165:10:0:42:-1 0/0:0,6,64:2:0:18:0 0/0:0,33,238:11:0:45:0 0/0:0,18,135:6:0:30:0 0/0:0,42,178:14:0:54:0 0/0:0,6,64:2:0:18:0 0/0:0,12,106:4:0:24:0 0/0:0,12,106:4:0:24:0 0/0:0,24,178:8:0:36:0 0/0:0,51,182:17:0:63:0 0/0:0,6,64:2:0:18:0 0/0:0,15,140:5:0:27:-1 0/0:0,24,153:8:0:36:-1 0/0:0,6,64:2:0:18:0 0/0:0,6,64:2:0:18:-1 0/0:0,24,178:8:0:36:0 0/0:0,15,122:5:0:27:-1 0/0:0,6,64:2:0:18:-1 0/0:0,0,0:0:0:12:0 0/0:0,18,154:6:0:30:0 0/0:0,3,35:1:0:15:0 0/0:0,3,35:1:0:15:0 0/0:0,15,122:5:0:27:0 0/0:0,12,106:4:0:24:0 0/0:0,30,165:10:0:42:-1 0/0:0,0,0:0:0:12:-1 0/0:0,6,64:2:0:18:0 0/0:0,0,0:0:0:12:-1 0/0:0,3,33:1:0:15:0 0/0:0,12,105:4:0:24:0 0/0:0,3,35:1:0:15:0 0/0:0,3,35:1:0:15:0 0/0:0,54,245:18:0:66:0 0/0:0,15,122:5:0:27:0 0/0:0,9,87:3:0:21:0 0/0:0,15,122:5:0:27:0 0/0:0,12,106:4:0:24:0 0/0:0,0,0:0:0:12:-1 0/0:0,21,145:7:0:33:-1 0/0:0,9,68:3:0:21:0 0/0:0,15,122:5:0:27:0 0/0:0,9,87:3:0:21:-1 0/0:0,24,151:8:0:36:0 0/0:0,18,148:6:0:30:0 0/0:0,12,106:4:0:24:0 0/0:0,63,184:21:0:75:0 0/0:0,9,87:3:0:21:-1 0/0:0,9,98:3:0:21:0 0/0:0,9,87:3:0:21:0 0/1:14,0,117:7:0:4:0 0/0:0,0,0:0:0:12:0 0/0:0,42,231:14:0:54:0 0/0:0,0,0:0:0:12:0 0/0:0,81,255:27:0:93:0 0/0:0,3,35:1:0:15:0 0/0:0,0,0:0:0:12:0 0/0:0,3,35:1:0:15:0 0/0:0,21,145:7:0:33:0 0/0:0,24,178:8:0:36:0 0/0:0,3,35:1:0:15:0 0/0:0,0,0:0:0:12:0 0/0:0,3,35:1:0:15:0 0/0:0,0,0:0:0:12:0 0/0:0,3,35:1:0:15:-1 0/0:0,0,0:0:0:12:0 0/0:0,0,0:0:0:12:0 0/0:0,3,35:1:0:15:0 0/0:0,54,211:18:0:66:0 0/0:0,3,35:1:0:15:0 0/0:0,18,135:6:0:30:0 0/0:0,3,35:1:0:15:0 0/0:0,54,208:18:0:66:0 0/0:0,12,122:4:0:24:0 0/0:0,3,35:1:0:15:0 0/0:0,15,122:5:0:27:0 0/0:0,9,99:3:0:21:0 0/0:0,12,106:4:0:24:0 0/0:0,15,122:5:0:27:0 0/0:0,33,220:11:0:45:0 0/0:0,33,197:11:0:45:-1 0/0:0,18,135:6:0:30:-1 0/0:0,21,145:7:0:33:-1 0/0:0,30,165:10:0:42:0 0/0:0,45,208:15:0:57:0 0/0:0,72,255:24:0:84:-1 0/0:0,15,132:5:0:27:0 0/0:0,21,168:7:0:33:0 0/0:0,21,153:7:0:33:-1 0/0:0,21,168:7:0:33:0 0/0:0,33,169:11:0:45:0 0/0:0,9,87:3:0:21:0 0/0:0,18,135:6:0:30:0 0/0:0,6,64:2:0:18:0 0/0:0,3,35:1:0:15:0 0/0:0,102,214:34:0:99:0 0/0:0,3,35:1:0:15:-1 0/0:0,24,153:8:0:36:0 0/0:0,6,64:2:0:18:0 0/0:0,9,87:3:0:21:0 0/0:0,0,0:0:0:12:-1 0/0:0,6,64:2:0:18:-1 0/0:0,18,135:6:0:30:0 0/0:0,0,0:0:0:12:0 0/0:0,3,35:1:0:15:0 0/0:0,12,122:4:0:24:-1 0/0:0,148,255:49:0:99:0 0/0:0,24,153:8:0:36:0 0/0:0,6,64:2:0:18:-1 0/0:0,3,35:1:0:15:0 0/0:0,15,122:5:0:27:0 0/0:0,9,87:3:0:21:0 0/0:0,3,35:1:0:15:0 0/0:0,3,35:1:0:15:0 0/0:0,18,135:6:0:30:0 0/0:0,18,153:6:0:30:-1 0/0:0,3,35:1:0:15:0 0/0:0,9,99:3:0:21:-1 0/0:0,9,87:3:0:21:0 0/0:0,3,35:1:0:15:-1 0/0:0,24,178:8:0:36:0 0/0:0,12,122:4:0:24:0 0/0:0,18,156:6:0:30:0 0/0:0,6,64:2:0:18:0 0/0:0,24,153:8:0:36:0 0/0:0,39,204:13:0:51:0 0/0:0,9,98:3:0:21:0 0/0:0,9,87:3:0:21:0
chr2 166747345 . TA TAACCAA 999.0 mrd10;sb0.05;tdb0.05;mrd15;mrp0.05 INDEL;DP=2010;VDB=0.0367;AF1=0.04555;AF2=0.1009,7.652e-06;LRT=9.18e-06;LRT2=3.71e-05;AC1=20;DP4=1559,232,39,0;MQ=35;FQ=999;PCHI2=0.00469;PC2=0,71;PV4=0.0069,1,1,4e-23;EFF=INTRON(MODIFIER||||TTC21B|retained_intron|CODING|ENST00000243344|),INTRON(MODIFIER||||TTC21B| retained_intron|CODING|ENST00000536175|),SPLICE_SITE_DONOR(HIGH||||TTC21B|retained_intron|CODING|ENS T00000243344|),SPLICE_SITE_DONOR(HIGH||||TTC21B|retained_intron|CODING|ENST00000536175|);MPB=U;ABPA= 25;ASTHMA=33 GT:PLSmilieP:SP:GQ:RES 0/0:0,90,255:30:0:99:0 0/0:0,18,126:6:0:28:0 0/0:0,168,255:66:0:99:0 0/0:0,39,203:13:0:49:0 0/0:0,36,243:12:0:46:0 0/0:0,105,237:35:0:99:0 0/0:0,3,35:1:0:13:-1 0/0:0,9,87:3:0:19:0 0/0:0,3,35:1:0:13:0 0/0:0,0,0:0:0:11:0 0/0:0,3,35:1:0:13:0 0/0:0,3,35:1:0:13:0 0/0:0,3,35:1:0:13:0 0/1:23,0,29:2:0:13:0 0/0:0,3,35:1:0:13:0 0/0:0,0,0:0:0:11:0 0/0:0,6,70:2:0:16:0 0/0:0,78,255:26:0:88:0 0/0:0,69,185:23:0:79:0 0/0:0,3,35:1:0:13:0 0/0:0,0,0:0:0:11:0 0/0:0,3,35:1:0:13:0 0/1:35,3,0:1:0:13:0 0/0:0,0,0:0:0:11:0 0/0:0,0,0:0:0:11:0 0/0:0,60,255:20:0:70:-1 0/0:0,3,35:1:0:13:0 0/1:29,0,18:2:0:19:0 0/1:25,0,29:2:0:15:0 0/0:26,32,85:3:0:16:-1 0/0:0,54,224:18:0:64:0 0/0:0,0,0:0:0:11:0 0/0:0,0,0:0:0:11:0 0/0:0,75,238:25:0:85:0 0/1:35,3,0:1:0:13:0 0/0:0,9,94:3:0:19:-1 0/0:0,0,0:0:0:11:-1 0/0:0,0,0:0:0:11:0 0/0:0,21,167:7:0:31:0 0/0:0,90,213:30:0:99:0 0/1:25,0,58:4:0:15:0 0/0:0,0,0:0:0:11:0 0/0:0,3,35:1:0:13:0 0/0:0,9,87:3:0:19:0 0/0:0,0,0:0:0:11:0 0/0:0,18,169:6:0:28:0 0/0:0,3,35:1:0:13:-1 0/0:0,15,122:5:0:25:0 0/0:0,6,64:2:0:16:-1 0/0:0,0,0:0:0:11:-1 0/0:0,0,0:0:0:11:0 0/0:0,12,106:4:0:22:0 0/0:0,12,119:4:0:22:0 0/0:0,102,255:34:0:99:0 0/0:0,24,151:8:0:34:0 0/0:0,12,106:4:0:22:0 0/0:0,9,98:3:0:19:0 0/0:0,9,98:3:0:19:0 0/0:0,87,255:29:0:97:-1 0/0:0,90,255:30:0:99:0 0/0:0,93,255:31:0:99:-1 0/0:0,22,163:14:0:32:-1 0/0:0,60,255:20:0:70:-1 0/0:0,57,255:19:0:67:-1 0/0:0,42,255:14:0:52:0 0/0:0,15,137:5:0:25:0 0/0:0,175,255:58:0:99:-1 0/0:0,21,166:7:0:31:-1 0/1:29,0,29:2:0:19:-1 0/0:0,48,234:16:0:58:0 0/0:35,35,35:1:0:11:0 0/1:26,0,55:3:0:16:0 0/0:0,12,110:4:0:22:-1 0/1:19,0,87:4:0:9:0 0/0:0,3,35:1:0:13:-1 0/1:16,0,93:5:0:7:0 0/0:0,6,70:2:0:16:-1 0/0:0,0,0:0:0:11:-1 0/0:0,72,185:24:0:82:0 0/0:0,6,70:2:0:16:0 0/0:29,32,61:2:0:13:-1 0/0:0,3,35:1:0:13:-1 0/0:0,202,255:67:0:99:0 0/1:35,0,124:9:0:25:-1 0/1:19,0,76:4:0:9:0 0/0:29,59,243:12:0:40:-1 0/0:0,6,64:2:0:16:-1 0/1:23,0,73:4:0:13:0 0/0:0,12,120:4:0:22:0 0/0:0,6,70:2:0:16:0 0/0:0,12,91:4:0:22:0 0/0:0,39,248:13:0:49:0 0/1:44,0,95:8:0:34:-1 0/0:17,32,134:6:0:25:-1 0/0:0,3,35:1:0:13:0 0/0:0,48,255:16:0:58:0 0/0:0,27,187:9:0:37:0 0/0:0,81,255:27:0:91:0 0/0:0,6,64:2:0:16:0 0/0:0,9,87:3:0:19:-1 0/0:0,9,87:3:0:19:-1 0/0:0,30,208:10:0:40:0 0/0:0,78,255:26:0:88:0 0/0:0,21,145:7:0:31:-1 0/0:0,21,183:7:0:31:0 0/0:0,57,235:19:0:67:0 0/0:0,21,184:7:0:31:0 0/0:0,0,0:0:0:11:0 0/0:0,3,35:1:0:13:-1 0/0:0,3,35:1:0:13:0 0/0:0,18,154:6:0:28:-1 0/0:0,21,141:7:0:31:0 0/0:0,15,140:5:0:25:0 0/0:0,24,180:8:0:34:-1 0/0:0,0,0:0:0:11:0 0/0:0,0,0:0:0:11:0 0/0:0,6,64:2:0:16:0 0/0:0,9,87:3:0:19:-1 0/0:0,9,87:3:0:19:-1 0/0:0,6,70:2:0:16:0 0/0:0,0,0:0:0:11:0 0/0:0,0,0:0:0:11:0 0/0:0,15,117:5:0:25:0 0/0:0,12,122:4:0:22:0 0/0:0,12,106:4:0:22:0 0/0:0,75,255:25:0:85:0 0/0:0,39,175:13:0:49:0 0/0:0,30,162:10:0:40:-1 0/0:0,6,70:2:0:16:0 0/0:0,0,0:0:0:11:-1 0/0:0,0,0:0:0:11:0 0/0:0,18,148:6:0:28:-1 0/0:0,0,0:0:0:11:0 0/0:0,30,191:10:0:40:0 0/0:0,18,144:6:0:28:0 0/0:0,45,255:15:0:55:0 0/0:0,0,0:0:0:11:0 0/0:0,12,106:4:0:22:-1 0/0:0,82,252:35:0:92:-1 0/0:0,6,64:2:0:16:0 0/0:0,0,0:0:0:11:0 0/0:29,32,44:2:0:13:0 0/0:0,9,83:3:0:19:0 0/0:0,6,64:2:0:16:0 0/0:0,39,228:13:0:49:0 0/0:0,12,102:4:0:22:0 0/0:0,48,210:16:0:58:0 0/0:0,0,0:0:0:11:0 0/0:0,0,0:0:0:11:-1 0/0:0,3,35:1:0:13:0 0/0:0,12,128:4:0:22:-1 0/0:0,3,35:1:0:13:0 0/0:0,3,35:1:0:13:0 0/0:0,6,64:2:0:16:-1 0/0:0,9,82:3:0:19:0 0/0:0,6,64:2:0:16:0 0/0:0,0,0:0:0:11:-1 0/0:0,3,35:1:0:13:0 0/0:0,0,0:0:0:11:0 0/0:0,3,35:1:0:13:0 0/0:0,3,35:1:0:13:0 0/0:0,0,0:0:0:11:0 0/0:0,6,64:2:0:16:-1 0/0:0,21,187:7:0:31:0 0/0:0,78,255:26:0:88:0 0/0:0,15,111:5:0:25:0 0/0:0,30,191:10:0:40:0 0/0:0,30,164:10:0:40:0 0/0:0,6,64:2:0:16:-1 0/0:0,6,64:2:0:16:-1 0/0:0,9,84:3:0:19:0 0/0:0,75,255:25:0:85:-1 0/0:0,63,255:21:0:73:0 0/0:0,39,200:13:0:49:-1 0/0:0,24,174:8:0:34:0 0/0:0,75,255:25:0:85:-1 0/0:0,81,213:27:0:91:0 0/0:0,72,244:24:0:82:-1 0/0:0,3,35:1:0:13:-1 0/0:0,6,64:2:0:16:0 0/0:0,18,133:6:0:28:0 0/1:16,0,93:5:0:7:-1 0/0:0,63,213:21:0:73:0 0/0:0,3,35:1:0:13:0 0/0:0,51,255:17:0:61:0 0/0:0,18,135:6:0:28:0 0/0:0,0,0:0:0:11:-1 0/0:0,123,215:41:0:99:-1 0/0:0,39,203:13:0:49:0 0/0:0,6,64:2:0:16:-1 0/0:0,15,137:5:0:25:0 0/0:0,0,0:0:0:11:-1 0/0:35,35,35:1:0:11:-1 0/0:0,0,0:0:0:11:-1 0/0:0,36,173:12:0:46:-1 0/0:0,6,64:2:0:16:0 0/0:26,32,85:3:0:16:0 0/0:0,12,103:4:0:22:0 0/0:0,229,255:76:0:99:0 0/0:0,96,255:32:0:99:-1 0/0:0,24,153:8:0:34:0 0/0:29,32,61:2:0:13:0 0/0:17,32,132:6:0:25:0 0/0:0,18,150:6:0:28:-1 0/0:0,3,35:1:0:13:-1 0/0:0,3,35:1:0:13:-1 0/0:0,13,151:11:0:23:-1 0/0:0,6,70:2:0:16:0 0/0:0,12,122:4:0:22:-1 0/0:0,6,64:2:0:16:0 0/0:26,32,85:3:0:16:0 0/0:23,32,97:4:0:19:-1 0/0:14,32,144:7:0:28:-1 0/0:0,12,106:4:0:22:0 0/0:0,21,144:7:0:31:0 0/0:10,0,135:7:0:3:-1 0/0:0,117,255:39:0:99:0 0/0:0,66,211:22:0:76:0 0/0:0,3,35:1:0:13:0 0/0:0,30,163:10:0:40:0
# 2  
Old 06-17-2013
It would be better to past your input file under code tags

This will extract you the last column on a tab delimited file..

Code:
awk -F"\t" '{print $NF}' file

# 3  
Old 06-17-2013
Code:
sed "s/.*:RES//" file

This User Gave Thanks to anbu23 For This Post:
# 4  
Old 06-17-2013
Something like this
Code:
awk -F":RES" '/:RES/ {print ":RES" $2}'

This will print from :RES to end of line for all lines containing :RES
This User Gave Thanks to Jotne For This Post:
# 5  
Old 06-17-2013
many thanks

the sed command worked well

---------- Post updated at 06:07 AM ---------- Previous update was at 06:05 AM ----------

as did the awk - many thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl to extract values and print at end of each line

In the below perl I am trying to extract and print the values AF1=, the GT value, and F or QUAL diveded by 33 (rounded to the nearest whole #). The GT value is at the end after the GT:PL so all the possibilities are read into a hash h, then depending on the value that is in the line the... (1 Reply)
Discussion started by: cmccabe
1 Replies

2. Shell Programming and Scripting

How can I extract digits at the end of a string in UNIX shell scripting?

How can I extract digits at the end of a string in UNIX shell scripting or perl? cat file.txt abc_d123_4567.txt A246_B789.txt B123cc099.txt a123_B234-012.txt a13.txt What can I do here? Many thanks. cat file.txt | sed "s/.txt$//" | ........ 4567 789 099 012 13 (11 Replies)
Discussion started by: mingch
11 Replies

3. Red Hat

How to add a new string at the end of line by searching a string on the same line?

Hi, I have a file which is an extract of jil codes of all autosys jobs in our server. Sample jil code: ************************** permission:gx,wx date_conditions:yes days_of_week:all start_times:"05:00" condition: notrunning(appDev#box#ProductLoad)... (1 Reply)
Discussion started by: raghavendra
1 Replies

4. Shell Programming and Scripting

Search a string in a text file and add another string at the end of line

Dear All I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies

5. Shell Programming and Scripting

sed - Find a String and append a text end of the Line

Hi, I have a File, which have multiple rows. Like below 123456 Test1 FNAME JRW#$% PB MO Approver XXXXXX. YYYY 123457 Test2 FNAME JRW#$% PB MO Super XXXXXX. YYYY 123458 Test3 FNAME JRW#$% PB MO Approver XXXXXX. YYYY I want to search a line which contains PB MO Approver and append... (2 Replies)
Discussion started by: java2006
2 Replies

6. Shell Programming and Scripting

Extract X words from end of line, minus last keynumber X

The file contains one line of text followed by a number. I want to take the number X at the end, take it out and display the last X words. X is the key telling me how many words from the end that I want and X will always be less than the number of words, so no problem there. Example input and... (4 Replies)
Discussion started by: fubaya
4 Replies

7. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies

8. UNIX for Dummies Questions & Answers

Using sed to extract a substring at end of line

This is the line that I am using: sed 's/^*\({3}*$\)/\1 /' <test.txt >results.txt and suppose that test.txt contains the following lines: http://www.example.com/200904/AUS.txt http://www.example.com/200903/_RUS.txt http://www.example.com/200902/.FRA.txt What I expected to see in results.txt... (6 Replies)
Discussion started by: figaro
6 Replies

9. Shell Programming and Scripting

extract a particular start and end pattern from a line

hi In the foll example the whole text in a single line.... i want to extract text from IPTel to RTCPBase.h. want to use this acrooss the whole file Updated: IPTel\platform\core\include\RTCPBase.h \main\MWS2051_Sablime_Int\1... (7 Replies)
Discussion started by: manish205
7 Replies

10. Shell Programming and Scripting

Extract digits at end of string

I have a string like xxxxxx44. What's the best way to extract the digits (one or more) in a ksh script? Thanks (6 Replies)
Discussion started by: offirc
6 Replies
Login or Register to Ask a Question