I don't quite follow what you're after. Could you please provide a sample input file, a desired output and the sample values for 'string1' and 'string2'.
Please use BB codes when posting sample data.
Apologies. I have just re-edited the last post, I hope it's easier to understand now.
Thank you protocomm, but I had what I needed. That doesnt search for a any pattern. Thanks anyways, it's helping me to understand how awk works
---------- Post updated at 11:00 AM ---------- Previous update was at 10:37 AM ----------
Quote:
Originally Posted by danmero
humm this returns what I need but I cant use it because the next line has not a reference string but the string in the line just before with the word "update" is the one I can use.
Thanks anyways
---------- Post updated at 11:18 AM ---------- Previous update was at 11:00 AM ----------
Quote:
Originally Posted by Kibou
Perfect, thanks so much. I have learnt a lot. So fast answering too.. thousand times thank you.
I have another problem..
When I have a "create table" I have several lines after, and then ");". I want to append all those lines but I dont know how many lines would it be, so the reference would be the final ");" line. How to add this new rule to the one you made before??
Your last statement:
So, I have found something like:
input:
output:
I am sorry this has turned into a more complex stuff.. thankful again.
---------- Post updated at 12:04 PM ---------- Previous update was at 11:18 AM ----------
Quote:
Originally Posted by Kibou
Thank you protocomm, but I had what I needed. That doesnt search for a any pattern. Thanks anyways, it's helping me to understand how awk works
---------- Post updated at 11:00 AM ---------- Previous update was at 10:37 AM ----------
humm this returns what I need but I cant use it because the next line has not a reference string but the string in the line just before with the word "update" is the one I can use.
Thanks anyways
---------- Post updated at 11:18 AM ---------- Previous update was at 11:00 AM ----------
I have another problem..
When I have a "create table" I have several lines after, and then ");". I want to append all those lines but I dont know how many lines would it be, so the reference would be the final ");" line. How to add this new rule to the one you made before??
Your last statement:
So, I have found something like:
input:
output:
I am sorry this has turned into a more complex stuff.. thankful again.
Another way of solving my problem would be a statement doing something just like finding a string1, deleting this line and the next lines until it finds another pattern in a line. This line that follows the other pattern wont be deleted.
If implementing this job, the last thing I requested before about "create table" wont be needed any more.
Also, if a line with just the string1 is found, delete that line.
It would be something like:
input:
output:
So I want to find the string /select/ in a line, delete it, and the next lines after, doesnt matter how many if they are not /(update | insert into)/ , for example.
Thank you.. and as I said, if doing this, I wont need to work what I said before about "create table".
---------- Post updated at 12:24 PM ---------- Previous update was at 12:04 PM ----------
Quote:
Originally Posted by Kibou
Thank you protocomm, but I had what I needed. That doesnt search for a any pattern. Thanks anyways, it's helping me to understand how awk works
---------- Post updated at 11:00 AM ---------- Previous update was at 10:37 AM ----------
humm this returns what I need but I cant use it because the next line has not a reference string but the string in the line just before with the word "update" is the one I can use.
Thanks anyways
---------- Post updated at 11:18 AM ---------- Previous update was at 11:00 AM ----------
I have another problem..
When I have a "create table" I have several lines after, and then ");". I want to append all those lines but I dont know how many lines would it be, so the reference would be the final ");" line. How to add this new rule to the one you made before??
Your last statement:
So, I have found something like:
input:
output:
I am sorry this has turned into a more complex stuff.. thankful again.
---------- Post updated at 12:04 PM ---------- Previous update was at 11:18 AM ----------
Another way of solving my problem would be a statement doing something just like finding a string1, deleting this line and the next lines until it finds another pattern in a line. This line that follows the other pattern wont be deleted.
If implementing this job, the last thing I requested before about "create table" wont be needed any more.
Also, if a line with just the string1 is found, delete that line.
It would be something like:
input:
output:
So I want to find the string /select/ in a line, delete it, and the next lines after, doesnt matter how many if they are not /(update | insert into)/ , for example.
Thank you.. and as I said, if doing this, I wont need to work what I said before about "create table".
That is, if I would have a pattern to say "delete this line when you find this pattern" I would simply say:
but the problem is that I dont want it to delete the line with update, but the line just before when it finds it :s
I keep trying.. I am really new to this awk/sed world..
Your requirement change from post to post. Try to decide what you need and post a data sample and required output.
Apologies for the confusing posts..
This is what I want: if "select" found in a line -> delete that line. Delete also the lines afterwards until it finds "update" in a line, but I dont want this line to be deleted, just the line before.
It would be something like:
input:
output:
That would be: clearing out all the lines with "select" and the lines that goes afterwards until it finds "update", but not deleting the line with "update".
I know I could simply do it like this,
but the problem is that I dont want it to delete the line with update, but the line just before when it finds it :s
Thank you,.. I dont know if this is possible. Sorry I was making a mess but there are several ways of getting the final result I want, and I just want to give to you the easiest way to have it done... thanks again
Hi
how do I join files like below in script.
Thanks,
Ashan
there are may line like this in the file.
zone name DR_TMP_A_sev1_3eA vsan 200
pwwn 50:00:09:73:f0:16:35:08
pwwn c0:50:76:08:6e:dc:00:16
zone name DR_TMP_A_SVR2_3eA vsan 200
pwwn 50:00:09:73:f0:16:35:08
pwwn... (4 Replies)
Hi,
I have a unix file which has many lines, i need to join all the lines to single line.
Eg: myfile.txt contains:
a
123
45fg
try
and i need the output as :
a 123 45fg try
Please help me on this.
Thanks! (2 Replies)
Hi,
I have been thinking of how to script this but i have no clue at all..
Could someone please help me out or give me some idea on this?
I would like to group those lines with the same first variable in each line, joining the 2nd variables with commas.
Let's say i have the following input.
... (3 Replies)
I have a file like this:
---------------------------------------------------------------
26
00:04:48,440 --> 00:04:51,440
I don't know why he can't just do
the Great Apache Flaming Arrow Act.
27
00:04:52,440 --> 00:04:54,839
Didn't you tell him
to use the gopher snake?
28... (1 Reply)
I want to join this two lines but only when after him
I have nothing or a comma
Yes, I know Jonesy, and I'll give him
about one more minute.
this two lines must become
Yes, I know Jonesy, and I'll give him about one more minute.
thank you very much (11 Replies)
hi all i have sample and i need script to do this
/dev/xxx oracle test
/dev/sap
9999 000 88 99
i need the out put like this
/dev/xxx oracle test
/dev/sap 9999 000 88 99
can any one provide me with an idea to solve this problem (8 Replies)
Hi All,
Currently, the output looks like this:
hdisk0
queue_depth:3
hdisk1
queue_depth:3
hdisk2
queue_depth:1
hdisk3
queue_depth:1
I need to change the format to look like this:
hdisk0 queue_depth:3
hdisk1 queue_depth:3
hdisk2 queue_depth:1 (8 Replies)
can anyone tell me as "how to join all lines in a file " using a shell script
Actually i have many files in a directory and for each file i want to join all the lines using a shell scrip .
Thanks in advance!!! (8 Replies)
Hi,
I have a file with on one line a uid, and on the next line a date. I am trying to make the to into one line.
Here's an example:
koppx
20031125
kraan
20031119
sarox
20031107
And this is what i want it to be:
koppx;20031125
kraan;20031119
sarox;20031107
I have been trying... (4 Replies)