Hi all,
I am stuck in a tricky situation where i want to search a substring from a line through shell script.What i meant by that is given in the example shown below:
Line :: This is the TEST(Message(with some tricky word)) from which i want to search.
Result substring should be : Message(with some tricky word)
How can i get only "Message(with some tricky word)" from the Line "This is the TEST(Message(with some tricky word)) from which i want to search." ?
I cant format a RegExp for this kind of search. Please help me to format such tricky Regular Expression with some useful commands .Thanks in advance.
To do things like this, one normally needs some 'anchors' or known targets. From your example I can assume certain things about character placement and parenthesis, but that may have been just the way you typed that one line.
Would like to see something along the lines of:
Message from user Joe (Sent 10/13/08(Fix the hard drive))
Print for PTR_1(Update 10/17/08(re-install driver complete))
Message for Sue(Sent 10/21/08(Out of disk space))
Are you trying to pull something like that apart?
Last edited by joeyg; 10-21-2008 at 09:29 AM..
Reason: Corrected spelling.
explanation:
.* - look for any number of any character (including none)
TEST - followed by TEST
(\{1\} - followed by 1 ( [and only 1, if you want it to match more than 1 use \{1,\}]
\( - remember what you match from now on
.* - look for any number of any character (including none)
\) - end remembering matches
)\{1,\} - followed by 1 or more )
.*$ - followed by 0 or more characters to the end of the line
s/<regex>/\1/ - will substitute (s) what the regex matches, with the first remembered item from the regex.
You have the line as a variable so why more tricky actions to get the same result?
It's sufficient if the grep command is successful..or have I missed something?
Hi,
I'm trying to make a grep to see if exists occurrences with a sentence like these:
grep -qi "message" file0 | grep -i $date | grep -vi "exception"
echo $?
1
If I execute without -q modifier I can find occurrences.
Someone could help me please?
Thanks and sorry for my English! (1 Reply)
Hi guys,
I need to append new data at the end of each line of the files. This new data is based on substring (3rd fields) of last column.
Input file xxx.csv:
U1234|1-5X|orange|1-5X|Act|1-5X|0.1 /sac/orange 12345 0
U5678|1-7X|grape|1-7X|Act|1-7X|0.1 /sac/grape 5678 0... (5 Replies)
Hi,
I have a number of files containing the information below.
"""""
Fundallinfo
6.3950 14.9715 14.0482
"""""
I would like to grep for Fundallinfo and use it to read the next line? I ideally would like to read the three numbers that follow in the next line and... (2 Replies)
Hi All
I have a line which is as below
1234567 Gagan Paswani zz23432 1000000000 1000000000 ASTHEYXX-RTUC zz23432
I need to extract the first occurence of zz23432 which will have the reg expression as
{2}{5}
Could you please assist as to how I can extract this... (3 Replies)
Hi gurus,
I am trying to figure out how to extract substring from file line (all lines in file), as specified position and specified legth.
Example input (file lines)
dhaskjdsa dsadhkjsa dhsakjdsad hsadkjh
dsahjdksahdsad sahkjd sahdkjsahd sajkdh adhjsak
I want to extract substring on... (5 Replies)
Dear Folks,
I am having a requirement to grep a word which could be a part of a substring of a file. Please help me with the command for korn shell.
Let me give you a example
I am having a file in which the data is based on positions.
Lets say
1-5 is Emp ID 6-10 is Emp Name 11-15 is Salary... (5 Replies)
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)
Hi All,
I have 2 programs running by the following names:
a_testloop.sh
testloop.sh
I read these programs names from a file and store each of them into a variable called $program.
On the completion of the above programs i should send an email.
When i use grep with ps to see if any of... (3 Replies)
Ok, I'm stumped and can't seem to find relevant info.
(I'm not even sure, I might have asked something similar before.):
I'm trying to use shell scripting/UNIX commands to extract URLs from a fairly large web page, with a view to ultimately wrapping this in PHP with exec() and including the... (2 Replies)