General :: How To Use Find With Two Lines Together

Jan 19, 2010

I am trying to search for

Code:
<cats>
Sports
</cats>

how do i use the find command to search for <cats>Sports The problem here is that the word Sports is in the next line of <cats> so I cant use -

Code:
find /test/upload/ -type f -name "*.xml" -exec grep -l "<cats>Sports" {} ; -print
How do I put the next line string?

View 8 Replies


ADVERTISEMENT

General :: Find Pattern And Comment Out 2 Lines After It?

Oct 14, 2010

How do yo find a pattern with sed or awk and then:

- add a # at the beginning of the line containing it

- and add a # at the beginning of the following 2 lines, too?

Say, I want to comment out the line containing "which 0launch" and the two lines following it:

if [ -x "`which 0launch`" ]; then
exec 0launch http://rox.sourceforge.net/2005/interfaces/ROX-Filer -S
fi

Expected result:

#if [ -x "`which 0launch`" ]; then
# exec 0launch http://rox.sourceforge.net/2005/interfaces/ROX-Filer -S
#fi

I need this because I do not want to comment out every line containing "fi", just the "fi" of this specific if statement.

View 3 Replies View Related

General :: Bash Script To Find Lines Containing Two Different Strings

Mar 13, 2011

I'm trying to write a bash script to find all lines containing two different strings in many files. I don't have access to egrep so I want to use sed for this purpose.

The files will look like this:
FileX
------
Info:18
Data:76
Contact:me@home.com
Start:1500

I want to generate a new file from these files with only the rows containing Data and Start. Something like this:
for y in `ls /file*.db`;
do sed '/Data|Start/p' $y > newfile
done

View 7 Replies View Related

General :: Filtering Out Duplicate Lines From A Find/grep Output

Mar 22, 2010

I have some big files of logs that contain errors printed by an app. They are most of the time relevant, however most of them are similar. So i figured i could check what happened between a time interval with a find.

Im using this one

Code:

And I get an output similar to this one.

Code:

Is there a way to condensate the output lines to get only one or two, indicating the start and last occurrence of a block? Or I need to create a program to do so?

Because right now I get thousands of similar lines, but when I'm scrolling through them i sometimes miss relevant information that i would've otherwise noted if it wasn't all that spammy.

View 10 Replies View Related

General :: Delete All Lines Containing A String, Plus 4 Lines Below It?

Jan 26, 2010

I've come across an unusual requirement for a service in my Ubuntu system.Simply put, I need to find a way to search for all instances of a term in a file, delete lines containing containing that term, and delete four lines below each instance of that term. ither that, or copy the entirety of a file to a new file and skip over all lines containing the term plus four below it.This sounds kinda weird, I know. Without going too far into detail, I either have to change the logfile format for a server I'm running which is a huge pain in the butt, or I can just run a script to edit an HTML report generated from said logs. (Said report is really just for managers to peruse, and I like my log format, so I'm pursuing option 2.)

View 4 Replies View Related

Ubuntu :: Find Word Print Out # Of Lines

Feb 17, 2010

this is driving me crazy. How can i in the terminal, display only the first 5 lines of say dmesg

View 7 Replies View Related

Ubuntu :: Using Sed Or Awk To Find And Delete Lines In A File?

Dec 21, 2010

I have a bunch of text files, all of them have a .txt extension. They are all located in subfolders of the /MyTextFiles folder (but could be anywhere, no idea what depth). If any line in any of the text files has the word "hello" I want to delete that entire line. I know sed and awk are made for this problem but I can't seem to get the syntax correct.

View 1 Replies View Related

Programming :: Find Pattern That Extends Over Several Lines?

Jun 12, 2011

Is there a convenient method to find a text pattern that extends over several lines? In this case:

Empty line
LineConsistingOfSingleWord

Preferably to return the line number where the pattern occurs to determine the first such after a known line number. In other words, in order to extract a block of text from within a file.

View 3 Replies View Related

Programming :: Sed: Find Pattern And Delete 5 Lines After It?

Mar 23, 2010

I am trying to edit a print file.

For every occurence of the ^L form feed character I need to remove 5 blank lines after it but still keep the ^L.

I am a rare user of sed and am ok with the basics but am struggling with this.

View 4 Replies View Related

Server :: Find A String In A File And Delete That Line As Well As X Lines After?

Jun 24, 2010

I need to find a string in a file ... then delete the line it is on, as well as the next 6 lines. Or, delete the line the string is on and all subsequent lines until the search finds the character "["

example:

filename = test.txt

contents:
[foo]
test>test
test>test
test>test

[Code]....

so, in this example. I'd like to search the file for string 'foo' and delete all lines from that line until [bar] (not deleting the line with [bar])

View 3 Replies View Related

Programming :: Bash Script To Find And Remove Similar Lines From Multiple Files?

Jun 5, 2009

I want to remove duplicate or multiple similar lines from multiple files. I.e. if I have four files file1.txt file2.txt file3.txt and file4.txt and would like to find and remove similar lines from all these files keeping only one line from these similar lines. I only that uniq can be used to remove similar lines from a sorted file.

View 9 Replies View Related

OpenSUSE :: Web - Screen Loads And After Initial First Few Lines Breaks Up Into Multiple Repetitions Of Lines

Apr 22, 2011

I have been experiencing a problem where the screen loads and after initial first few lines breaks up into multiple repetitions of lines. Reloading helps but has to be repeated when pageing down. Mail is no problem; it is supplied by my network provider. OS is openSUSE 11.2 which I update when advised. Below is a sample from the error console:

[Code]...

View 1 Replies View Related

Ubuntu :: Wobbly Windows Lines - Get These Lines When Drag/move The Window Upwards

May 31, 2011

I've just installed Kubuntu 11.04, switched on wobbly windows effect. It runs very smooth on my Nvidia GeForce 7600 GS with dual screen twinview turned on. However, I get these lines when I drag/move the window upwards - see screenshot:

View 6 Replies View Related

Programming :: Remove Lines And Parts Of Lines From Python Strings?

Nov 24, 2009

How do you remove parts of strings using python? Such as, if I have something like:

Code:
erme1 sdifskenklsd
erme2 sdfjksliel

[code]....

View 3 Replies View Related

General :: Replace Several Lines In A File With Other Lines In Another File?

Oct 26, 2009

I have this massive table file with some data in it and I want to replace some lines that are wrong with the correct ones that are in another table file of the same format. The wrong lines are not all together in a block but randomly distributed so I need to make a loop checking if the line is in the other file and if it is, replace it. I want to try and do it with sed or awk but I don't really know how to....

View 12 Replies View Related

General :: Awk Group 2 Lines ?

Jul 15, 2011

I have a file with n number of lines where every 2 lines are grouped.

So I want to print the items in a line and the next line in a single line.

For example:

I can print the line and the adjacent together and print the required items like this:

But that's not the order I want. How can I get it printed like below:

View 1 Replies View Related

General :: Why Does AWK Split Lines Into Two

Aug 5, 2010

when I run the following command:

awk -F, '{print $10 "," $5 "," $1 "," $3 "," $4 "}' myfile > tmpfile

tmpfile displays the lines but they are all cut off and placed on the line below at the same point.

View 1 Replies View Related

General :: Deleting Several Lines In Vim?

Mar 5, 2011

I've a big text, and I would like to delete several lines in vim. I was thinking in doing that with marks, but I can't do it. Below it's an example text and I want to delete from <FROM HERE> to <TO HERE>. How can I do that?
[Quote] .....

View 3 Replies View Related

General :: Get The Lines With Only Five Characters?

Nov 2, 2010

I have a file with a random word on each line (3k+ lines). How can I get the lines with only five characters? I tried using grep file | more, but it returns all the words (even those less than 5 characters).

Edit: I also tried grep '.{5}' file | more but it doesn't show anything. And grep '.{5}' file | more returns all lines with four or more characters (I'm really confused about why it's doing this).

View 4 Replies View Related

General :: Need To Remove Lines With Sed

Mar 14, 2011

I have a large file and need to remove all the lines containing symbol/symbols.

For example: . , ! " # $ % & / ( ) = ? � � ' � + * � { } ] [ - _ : ; , > < (maybe more)

View 13 Replies View Related

General :: SED Or AWK - Remove Every 4 Of 5 New Lines

Aug 30, 2010

I have a file that looks like this:

1
2 3 4 5 6 7 8 9
10 11 12 13 14 15
16 17 18 19 20 21
22 23 24
1
2 3 4 5 6 7 8 9
10 11 12 13 14 15
16 17 18 19 20 21
22 23 24
1
2 3 4 5 6 7 8 9
10 11 12 13 14 15
16 17 18 19 20 21
22 23 24
...
I would like to reformat it to look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
...
Is there a nifty awk/sed one-liner to do this operation?

View 6 Replies View Related

General :: Using Vim To Add Something To End Of Series Of Lines

May 15, 2011

I would like to use VIM to add something to the end of a series of lines. Ideally I could do something like add " X" (with a space before the X) to the end of lines 1-40 and 50-60 in a single command, i.e. ideally I could have a break in between where I didn't add something. If that's not possible just adding to 1-40 and 50-60 separately would work too. I would be using bufdo to do this, but my understanding is that anything you can do in vim you can use with the bufdo command.

View 3 Replies View Related

General :: What Are Red Lines In Terminal

Mar 16, 2010

I've cross compiled busybox with buildroot for the mini2440 (configured: arm920t EABI) I compiled it dynamically. I use Ubuntu 9.10 on my build system. Doing the "ls -l"-command in the /bin directory I see that busybox is marked red. (This is still on my build system, not on my target system!) The background of the word busybox is marked red. And the word busybox is in default colour instead of yellow, even though all permissions have the executable sign. I was wondering what this means. Also whether it's a bad thing? Also could this mean this is why my mini2440 will not boot correctly after transferring this root file system? (It stops the booting process just after loading the root file system)

View 8 Replies View Related

General :: Why Seq 10 Sed Just Delete Three Lines

Jun 30, 2011

Code:
[root@station3 ~]# seq 10 | sed -e '1,2d' -e '1,2d'
4
5
6
7
8
9
10
We can see that sed just deletes the first three lines. How "seq 10 | sed -e '1,2d' -e '1,2d'"works?

View 1 Replies View Related

General :: Add Characters To Several Lines In A File?

Apr 17, 2009

I would like to modify the content of a text file in Linux, in the following way:=> the file has several of these lines:./run_pest3 ./g134366.04080_0.062 x 2_d043 1 0.43 results_EC=> I want to modify all lines to be:./run_pest3 ./g134366.04080_0.062 x 2_d043 1 0.43 results_EC0.062i.e., the last number of $2 should be "attached" to the end of $7, for each line.

View 5 Replies View Related

General :: Vim: Tab-align Multiple Lines?

Apr 14, 2010

In GUI style editors, you can generally select multiple lines, press tab a few times to move all the lines across (or shift-tab to go back). I have no idea how to do this in VIM.I googled around and couldn't find any straight answer to I came here.

View 2 Replies View Related

General :: Commented Out Lines In Crontab Still Run?

Sep 20, 2010

Silly question here. My crontab looks like this:

Quote:
0 22 * * * /usr/sbin/logrotate /var/log/VRTSralus/VRTSralus.logrotate
#0-59/10 * * * * /root/memmon.sh >> /var/log/memmon.txt
0 8 * * 1 /root/SHC.sh
#0 21 * * * /root/scripts/ralus_restart.sh > /dev/null 2>&1

As you can see two of the lines are commented out. However, both commented out commands are still running. I get emails stating that the RALUS agent restarted (another mystery since it's supposed to go to dev null according to the line above), and I can see that the memmon script is also running daily. Am I missing a step? Some other place I should be looking? Commenting out lines in your crontab is pretty much a no-brainer, so I appear to have less than no brain as this is a mystery to me.

View 5 Replies View Related

General :: Concatenate Data From Different Lines?

Mar 1, 2011

I want to concatenate info from different lines from iptables.for exmaple, in my firewall using iptables I have this information.

pkts bytes target prot opt in out source destination
0 ACCEPT all -- * * 192.168.1.3 0.0.0.0/0
5 248 ACCEPT all -- * * 0.0.0.0/0 192.168.1.3

[code]...

View 1 Replies View Related

General :: Get Rid Of Surplus Comment Lines With Sed?

Feb 14, 2011

I have a large text file and I have some comment lines in it beginning with $.

Now here is the challenge there are some lines where there is actually a written comment after $ (with some blanks between)

Then there are lines with only $ on it - with maybe some trailing spaces.

I would like to delete these dummy lines...

Lets say from

$ This is valid comment
$
$
$

[Code]....

View 3 Replies View Related

General :: Extract Lines From File Using AWK ?

Aug 5, 2010

I have a file similar to this:

I need to print the last line for each user into a file. The resulting file should look like this:

Is there a way that AWK can match lines from $1 and then print the last line into a file?

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved