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.
Hi,
Suppose I have a file with many lines as follows. Now I want to find the following questions from the file through shell script or commands.
Code:
My name is XYZ. XYZ works for GHT and XYZ is part of PES. GHT is a good organization. XYZ knows swimming. XYZ is also very keen in reading.
I need to remove lines from a text file based on pattern but I need to keep the first n lines of that pattern.
Input
% 1
% 2
% 3
% 4
% 5
text1
text2
text3
output
%1
%2
text1
text2
text3
I used sed /^%/d file but it deletes all the lines starting with %, sed 3,/^%/d doesn't help either. I need to keep first n lines of the pattern and delete the rest
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
Hi friends,
I am looking for sed command/script that would search for a given fixed pattern on odd lines and then if it matches, prints the matching pattern and the next line.
I have an MRTG configuration file containing some lines starting with the word "Target". Now in such lines there is a pattern starting with the character "#" and end with character ":".
I need to print out sections (varying numbers of lines) of a file between patterns. That alone is easy enough:
Code:
sed -n '/START/,/STOP/'
I also need the 3 lines BEFORE the start pattern. That alone is easy enough:
Code:
grep -B3 START
But I can't seem to combine the two so that I get everything between the patterns PLUS the 3 lines before the start of the pattern.
Hey everyone,
I've to count lines from string of files names then to show sum output of lines.
for example:
read x = F1 F2 F3
F1 = 12 lines
F2 = 14 lines
F3 = 10 lines
= 36
what I did is:
Code:
read x
echo $x >|temp
for x in $(cat temp)
do
wc -l < $x
done >| temp2
Hi All,
Need a small help in writing a shell script which can delete a few lines from a file which is currently being used by another process.
File gets appended using tee -a command due to which its size is getting increased.
Contents like :
Code:
[INFO] 25/09/2012 05:18 Run ID:56579677-1
My requirement is to remove lines which are more than 1 month old...