I have a sample text file with file name: sample.txt
The text file has the following text.
I want to extract n (a constant) words before and after a certain word. For example, I want to extract 2 words before and after the word "words" in the sample text above. The output that I expect is:
This is what I have attempted:
and the output that I get is this:
,where [white-space] represents " ". Now when I increase the window size from 2 to 10 in the code above like this:
I get the following output:
Therefore, one can see that the above code is considering characters before and after and not words. I am using BASH.
Last edited by Don Cragun; 11-02-2015 at 04:07 PM..
Reason: Change ICODE tags to CODE tags.
I have an assignment and I am not sure what to do.
In Unix, I use PuTTY
change the semicolon (;) to a period, and capitalize the first letter of the word immediately after it.
I know change command is M-% and "." so only one semicolon is changed but I am not sure how to... (1 Reply)
Hi all,
I have 7 words
Now I have 1 file which contain data in large number of rows and columns
and 6th column contain any of these words or may be more than one words among above 7 words:
I want
script should search for the above mentioned 7 words in the 6th column
... (9 Replies)
Hi,
i've a string
/u/user/DTE/T_LOGS/20110622_011532_TEST_11_HD_120/HD/TESi T_11_HD_120/hd-12
i need to get string, like
/u/user/DTE/T_LOGS/20110622_011532_TEST_11_HD_120/HD
the words from HD should get deleted, i need only a string till HD, i dont want to use any built in... (4 Replies)
hi
I have posted it earlier but i was unable to put my exact problem.This time posting in parts.
I have a text file which i had transferred to UNIX.It has strings like:
alter table table_name add (column_name);
as well as modify options.
now i need to read the table name between alter... (3 Replies)
Hi,
I want to print all words till the last word after the match of "ERROR" word. For e.g.
I'll get an sqlplus error with
e.g. 1
$ ./calltest_fn.ksh
var test_var:=test_fn1; calltest_fn.ksh file1 file2 file3 ERROR at line 4: ORA-06550: line 4, column 11: PLS-00201: identifier... (5 Replies)
Hi Guys, :p
I have a file like this:
2010-04-25 00:00:30,095 INFO - ]- start process U100M4
2010-04-25 00:00:30,096 DEBUG - ] -- call EJB
2010-04-25 00:00:30,709 INFO - - end processU100M4
2010-04-25 00:00:30,710 DEBUG - got message=Sorry
I want to out put format.
2010-04-25... (5 Replies)
Dear,
Can somebody help me with this?
I have a variable
TGT=T2DIRUPDAZ20070326VA
I want to get in variables some part of TGT. like this.
TGT1=UPDA
TGT2=20070326
TGT3= VA
These three variables have fixe position in variable TGT. (2 Replies)
Hi,
I am trying to filter the words from a file which contain 'abc'. But I am unable to. Could any one help me.
For eg: The file contents are
123ab 12hnj1 123abc456 123cgbcahjkf23 23134abchfhj43 gc32abc abc1 2abc3 sd uiguif fhwe 21242 uh123 jkcas124d123 u3hdbh23u ffsd8
Output... (3 Replies)
how do i get a word that exists between two words
eg: this is bryan
My input to command would be this and bryan
and output should be 'is'
Is there a command i can use? (4 Replies)
Hi,
I have a Template file 'TL.body' which says as follows:
"There are no <FILENAME> files on the server. "
The missing file names are identified and stored in a variable.
For Eg: MISSFILE="abc.txt def.txt xyz.txt"
I want the values of MISSFILE variable to be replaced against... (2 Replies)