I am trying to delete lines in archived Apache httpd logs
Each line has the pattern:
<ip-address> - - <date-time> <document-request-URL> <http-response> <size-of-req'd-doc> <referring-document-URL>
This pattern is shown in the example of 6 lines from the log in the code box below. These 6 lines are in a row, and all start with same IP address.
I would like to write a script that takes something like this:
Line 1
Line 2
Line 3
Line 4
[Blank line]
Line 6
Line 7
Line 8
Line 9
[Blank line]
etc....
And makes it to look like this:
Line 1|Line 2|Line 3|Line 4|[Blank line, if it's easier]
Line 6|Line 7|Line 8|Line 9|[Blank line, if it's easier]
etc.
I would think it would be fairly easy to use two loops, one for the the 5-li
In a bash script using sed how can I remove a block of lines beginning with -pattern a- and ending with -pattern b- where the the contents contains -pattern c- ( or does NOT contain -pattern c-)?
So :
line 1 -pattern a-
line 2
line 3 -pattern b-
line 4 -pattern a-
line 5 -pattern c-
line 6 -pattern b-
In this example I want to remove lines 4,5 and 6 (or remove 1,2 and 3 for not cont
Is it possible to do it in one liner?
I have an output like this:
"First line" - Description
" Second line" - Description
"Third line" - Description
" Fourth line" - Description
This input is generated automatically.
I want to replace the first occurrence of " (quotation mark + space) with " (quotation mark) for each line.
Hi everyone,
I am new to shell scripting, and would appreciate your help on following problem.
I need to search a file for a pattern, then get the number of each line that matches the given pattern.
Then I need to search those specific line numbers from the first file in a second file and print the entire lines.
I tried with grep -n 'pattern' from the first file, which gives me:
21: pat
What I try to accomplish with 'sed' is to remove a line if the pattern match.
and adding a line if pattern doesn't match.
But how could I make this?
Thanks in advance
Example:
I want this to use this line in Crontab:
*/1 * * * * script 1 test
With a other script I want to remove this line if this pattern is there, and otherwise, if pattern is not matching then add this line.
Hi
Im trying to do the following in sed. I want to delete any blank line at the start of a file until it matches a pattern and then stops.
I need to print N lines before a pattern ERR-XXXXX .
can any one help how to stop search pattern end of line. It means i am searching one pattern from line 1 and search when it reaches the end of line in a file it should be stop.