I am facing a problem and I would be grateful if you can help me
I have a list of words like
Quote:
the and of ...
And I have a datafile like
the box of
the box of tissues out of
of tissues out of
the book, the
the book, the pen and the
the pen and the
I want to find Patterns of “x.*x” where x are the words mentioned, meaning that each line with start with X and followed/finished by X, such as
The.* the
The.* of
The.* and
Of.* the
.
.
But I need each of them to be saved in a different file so one file for “the.*the” and so on.
I would previously create a acceptfile of the words, such as
the
of
and
.
.
.
and read a normal pattern from an acceptfile using
But the problem here is that I look for a substring and not a single word and GREP acceptfile is not reading my “x.*x” if i type that in my acceptfile
On the other hand, I used to use grep for substring patterns matching
but now that I have about 10 words and I want all of them to be compared to each other, I would have around 100 patterns of “x.*x” and I don't want to manually sit and put them in
I am new to unix but I am sure there should be way to do this but not yet sure how.
Note: I don't necessary need to use GREP but this is just what I am familiar with now but happy to learn new things
I would be amazing if you can help me
Thank you in advance
A-V
---------- Post updated at 09:32 AM ---------- Previous update was at 07:09 AM ----------
or it may be simpler to say i have a array or file called X
Quote:
where X = [the of and ...]
and another one called Y
Quote:
where Y = [the of and ...]
the command looks like this
i guess i would need a loop to go through each one of the Xs and each one of the Ys and put them either in separate column or file like
Quote:
the-of pattern result
the-the pattern result and etc
I am really trying my best but dont know what to do
What is the goal, the reason you are doing this, not how you chose to do it.
It looks like you are still stuck on square zero. So let's go back and detemine your requirements. I'm sure you do not want just to play with grep or ls. You want to do something with the files, or report something in the files.
This User Gave Thanks to jim mcnamara For This Post:
I am not an expert with linux, but following various posts on this forum, I have been trying to write a script to match pattern of charters occurring together in a file.
My file has approximately 200 million characters (upper and lower case), with about 50 characters per line. I have merged all... (5 Replies)
The sample file:
dept1: user1,user2,user3
dept2: user4,user5,user6
dept3: user7,user8,user9
I want to match by '/^dept2.*/' but don't want to have substring 'dept2:' in output. How to compose such regex? (8 Replies)
Hi,
I have a string looks like the following:
USERS 32767.9844 UNDOTBS1 32767.9844 SYSAUX 32767.9844 SYSTEM 32767.9844 EMS 8192 EMS 8192 EMS_INDEXES 4096 EMS_INDEXES 4096 8 rows selected.
How do I extract a sub-string to get the expected output as following:
EMS 8192
EMS_INDEXES 4096
... (3 Replies)
Hello sorry for the probably simple question - searching about the forums and Internet, I have not found the answer.
Could you tell me please how to do a multiple pattern match with SED
So it would be SED searching for "PATTERN1" 'or' "PATTERN2" not 'and' if they happen to fall on the same... (4 Replies)
I have a file a file having entries are like
@ram@sham@sita
@krishan@kumar
@deep@kumar@hello@sham
in this file all line are having different no of pattern-@.
need to fetch the substring after the last pattern.
like
sita
kumar
sham
thanks in advance (3 Replies)
I figured this would be simple, but I am stuck.
Variable longpath="/dir1/dir2/dir3/filename.stuff.morestuff.garbage"
I want to end up with just "filename.extra.moreextra". So, I want to get rid of the path and .garbage
I want to do this with just ksh internals. So, no sed,grep,awk,expr,... (4 Replies)
Hi everyone, and thank you for your help with this. I am VERY new with perl so all of your help is appreciated. I have tried google but as I don't know the proper terms to search for and could be daunting for a newbie scripter... I know this is very easy for most of you! Thanks!
I have a... (4 Replies)
I've got a longish log file with content such as
Uplink traffic:
Downlink traffic:
I want to parse the log file and remove any line that contains the string "Uplink traffic:" at the beginning of the line, but only if the line following it beginnings with the string "Downlink traffic:" (in... (7 Replies)