General :: Grep To Select Lines With M In Last Word

Mar 6, 2011

I have a large file in which each line has three or more blank-delimited words. I'd like to code a grep to keep only those lines which have the letter M in the last word. the M (if present) will be the first character in the last word.

View 14 Replies


ADVERTISEMENT

Ubuntu :: Select Lines Containing Word And Copy To Another File?

May 31, 2011

I am trying to find a way to search a text file for a certain keyword and then select each line containing the word , copy and paste these lines into another text file. I can do this easily with UltraEdit but I cannot figure out how to do it in Jedit or Scite.

View 5 Replies View Related

General :: Get A Word From A Line Using Sed Or Grep

Mar 30, 2010

I am trying to get a word from a line using sed. Following is the line which I want to use.

inet addr:10.245.86.15 Bcast:10.245.87.255 Mask:255.255.254.0 inet6 addr: fe80::1031:3dff:fe01:55e1/64 Scope:Link

From the above line, I need the ip address like 10.245.86.15 only.

View 4 Replies View Related

General :: Search A Grep For A Magic Word?

Feb 16, 2011

I am using ascript for general users to back up usb drives to lto4 tapes.. I wish to ahve some error checking to check IF is there is a tape in the tape drive to check for the tape:

if i do a
sudo mt -f /dev/st0 status
i will get back a
mt: /dev/st0: rmtioctl failed: Input/output error
if there is no tape in the drive or
sudo mt -f /dev/st0 status

[code].....

View 4 Replies View Related

General :: Inserting Same Word On Different Lines In Vi

Aug 2, 2011

I am having problem in adding a word in same place on different line in vi editor (/bin/bash).

View 4 Replies View Related

General :: Finding Surrounding Lines With Grep?

Aug 7, 2010

I know how to use grep to output a line that matches a string. But what if I also want to output one line above every line containing a matching string, how do I do that?

View 1 Replies View Related

General :: Grep - A-Z - Returns Unmatched Lines ?

Feb 21, 2011

Does anyone know why something like:

echo lowercase | grep [A-Z]

Would still return the lowercase line even tho there is no match?

Using --color will show there is no match but the line is still returned.

I am still new but from what i've learned this should not work like that. ubuntu 10.10

View 13 Replies View Related

General :: Grep And Store Two Lines In Other File

Feb 16, 2011

I have following contents

I want to grep "#2" and want the output as

How to using shell script?

View 6 Replies View Related

General :: Grep Varying No. Of Lines Between Two Patterns

Apr 11, 2011

I have a file that goes like this:

I need to grep the lines between pattern 1 and pattern 2 and not the lines following pattern 2. Cannot use grep -A(num), as there are varying number of lines following pattern 1. Also, used awk one-liners, but results are erroneous.

View 14 Replies View Related

General :: Use Grep To Match Multiple Lines?

Feb 3, 2011

I have done this before but i cant really recall now

I have a text file and i want to grep the word "interface" and 10 lines following it. I think there was some switch like grep -A or something ?

View 2 Replies View Related

General :: Grep Multiple Lines From A Text File

Jun 17, 2009

I have a list of words that I want to grep in many files to see which ones have it and which ones dont. in the text file I have all the words listed line by line, ex: list.txt:

check
try this
word1
word2
open space
list ..

I want to grep each line one by one. like I want it to

grep "check" *.log
grep "try this" *.log
grep "word1" *.log .. etc how can I do this?

and maybe write the output to a file.

View 5 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 :: Select Lines From FileA Based On A Key Field In FileB

Feb 11, 2011

I want to select lines from FileA based on a key field in FileB.

egrep does this nicely:
"egrep -w '0132874|0132880|0100765' < " FileA

Suppose FileB consists of three lines:

0132874
0132880
0100765

Is there a way to code egrep to do the selection? I really like code which does not use explicit loops so my interest is to find a grep or egrep or sed (or some other) command to perform this function.

Neither file is sorted on the key field but they could be. There is no requirement to keep the files in their present order.We may assume that each key value in each file is unique.

View 2 Replies View Related

General :: Find/grep/wc Command To Find Matching Files - Print Filename And Word Count?

Sep 11, 2009

I am trying to do a find/grep/wc command to find matching files, print the filename and then the word count of a specific pattern per file. Here is my best (non-working) attempt so far:

wc `find . ( -name "*.as" -o -name "*.mxml" ) -exec grep -H HeightResizableList {}` ;

View 10 Replies View Related

Programming :: Deleting Lines Above And Below A Word

Mar 25, 2011

i jst want to delete a host entry from httpd.conf the entry for lal.com should be deleted!!

View 14 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 :: Opening Word Docs - Brings Up Is Lines

Jul 19, 2011

I took all my docs of my pc and put them on a usb drive and now have moved them onto ubuntu. However, when I open them with openoffice, all it brings up is lines and lines like this... how I can fix this and get my documents back to normal again?

View 3 Replies View Related

Software :: Delete Top Lines Of A Text File Until A Word Is Met?

Jul 7, 2011

I need to chop of the top 30ish lines of several log files until a line starting with "Initialization completed."The trouble is that it's not always the same amount of lines that need to be deleted, and they don't always contain the same information, which is why I would need to delete everything priorhe line starting with "Initialization completed."Right now I have a little script I wrote based on looping each file through several "grep -v" commands with each known pattern of lines I want to ignore, but it is tedious and I have to inspect each file afterwards to make sure nothing is left from above "Initialization completed

View 3 Replies View Related

Programming :: Displaying Particular Lines Via Grep ?

Apr 8, 2011

So For example I run this command:

Code:

But want to gerp / cut it in such a way that it only displays

Code:

Now the thing is that these 3 lines are not static.. there can be N number of lines there.. the only thing is that I want the command / output NOT to display the first line but the rest of the n lines ..

View 9 Replies View Related

General :: Grep Lines Containing A Certain String PLUS The Line Following That Line?

Sep 1, 2009

I have a dataset (see example below) that I would like to go through and copy all lines containing a certain string ("LGIG") plus the line immediately following that line to a new file. I have no problem grepping lines containing the string LGIG but I'm lost how to translate that to line number and shift up one line number for each instance of that string.

Example input file:

[code].....

View 5 Replies View Related

Programming :: How To Grep Pattern Which Is Split In 2 Lines?

Dec 9, 2010

I need to grep a pattern which can be present in one line or could be split in 2 lines.Normal grep wont work in this case. Can anyone please help on this?There are 100's of files in which i need to search for this pattern so time is also a constrain.

View 5 Replies View Related

Programming :: Get Rid Of Unwanted Lines Without Grep -v In BASH?

Jun 9, 2009

I would like to know how I can get the ouput from the following dmidecode command in example 1 to look like example 2 without having to grep -v all the unwanted lines.Is there a way in awk or sed?Example 1

Code:
Processor Information
Socket Designation: Socket 1 CPU 1

[code]...

View 7 Replies View Related

Programming :: Use Grep To Fetch Lines Contain 'AB_001'

Sep 17, 2010

I have such a file(test.txt) as below:

[code]...

I want to use grep to fetch the lines contain 'AB_001'.

[code]...

get the first 2 lines, not the 'AB_0011/10/105'.

View 2 Replies View Related

Programming :: Substitute Few Words + Change All The Lines Starting With A Specific Word + Put Blank?

Jan 17, 2009

I have an old-address-list file which is having around 1500 entries. I need to convert this addresses in to a specific format.

The old-address-list file>
# cat old-address-list-file
dn: CN=Muhammad Hadhi K.M,OU=IT Dept,OU=Example Company H.O,DC=example,DC=com
cn: Muhammad Hadhi K.M

[code]....

View 6 Replies View Related

General :: Search Word And Delete Only The Word And The Line Using Sed Command?

Jun 28, 2011

Want to search for ~ and delete it as well as to append the entire line to the above line. For Ex:

1111xxxx date Sandy area is ~around this area.3222xxx date There seems to ~left side of map, the colours are accurate (showing green areas)Even if I ~zoom in, the green parks, xxx3258 date The dammed up
~away, the "other" body of water varies ~blackNatural gas leaching.

IT MUST LOOK LIKE:

1111xxxx date Sandy area is around this area. 3222xxx date There seems to left side of map, the colours are accurate (showing green areas)Even if I zoom in, the green parks, xxx3258 date The dammed up away, the "other" body of water varies blackNatural gas leaching.

View 4 Replies View Related

General :: Sed Append Word At End Of Line If Word Is Missing

Feb 19, 2010

I have to modify formsweb.cfg file in Oracle IAS.

Problem description

In formsweb.cfg file are two lines with labels archive_jini= and archive= at the beginning of line. After equal sign (=) is row of filenames of java archives delimited by coma(,). When I insert a new jar file in java directory, I have to append the very same name of jar file to both lines if that name is not yet present.

Example snippet from formsweb.cfg

View 2 Replies View Related

Programming :: Read Two Files Word By Word At A Time Using Any Loop By Shell Script?

Mar 4, 2010

Well, I am facing one issue:How can i read two files word by word at a time using any loop as i need word by word comparision in shell script?Please let me know pseudo code.

View 14 Replies View Related

Programming :: Bash Shell Script Read File Word By Word?

Jan 21, 2011

I have a output file look like this:
{"test1" : "test2", "test3" : "test4"},

How can I read word by word in each line?This is not working code:

a=0
while read word
do a=$(($a+1));

[code]...

View 14 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

General :: Next Word Of A Particular Word ?

Feb 9, 2011

In linux is there a way to find the next word of a particular word of a file. grep displays entire line of the particular word. But i want only the exact next word of that particular word.is there any command for that.

View 13 Replies View Related







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