General :: Delete Only First Hit /match With Sed?

Jan 23, 2011

$ echo -e "AsometAhingA
somethingA
ASomethiAng"
AsometAhingA[code]....

I know that sed "s/A//" deletes the first match in every line.But i want to delete only the first match in a txt. like: sed -i "MAGIC" file.txt

View 3 Replies


ADVERTISEMENT

General :: Use Sed To Delete All Lines Before First Match Of A Pattern?

Apr 14, 2010

I have to use sed with this problem, and sed is extremely complicated, they could probably teach a whole class on this entire function.

Here's an example to show what I need to do:

Code...

how would I say that every line before I reach the first match of "sweet" should be deleted so that the output will look like: Code...

View 9 Replies View Related

Programming :: Delete Lines Between Match?

May 15, 2011

My problem is like this I have to delete all lines between two pattern match example- suppose below is the content of the file then i have to delete all lines between text1 and text2

...
text1
abc
def
ghi

[Code]....

View 14 Replies View Related

Programming :: Perl - Delete Line From Text File With Duplicate Match At Beginning Of Line

Apr 1, 2009

Was wondering if any perl guru's could help me with a quick log file adjustment. I have a text file that looks like so (tabs and newlines are revealed so you can see what separates the data):

There are maybe 100 lines of text in this file at any given time. I need to delete all duplicate lines only looking at the first bit of text prior to the first tab. It doesn't matter which one gets deleted as long as there are no two lines that begin with that same text at the beginning before the first tab. So in this example, either the fist line "1234" or the last line "1234" would need to be deleted. I already have code in my script that opens the files - I just need the code to read the text into an array and the part that would find matches based on the above criteria, and make the deletions.

If it would be easier, I can even do a system call and use SED (v4.1.5) and/or AWK (3.1.5) instead.

View 7 Replies View Related

Programming :: Match Datetime By The Minute (not An Exact Match By The Second)

Oct 21, 2010

I have the following query:

Code:
$sql="SELECT table1.datetime, table1.user_id, table2.ip, FROM table1,table2 WHERE id='$id' AND (table1.id = table2.id AND table1.datetime = table2.datetime)";

In table2 the datetime fields are about 1 to 2 seconds off due to the source of the data, which I cannot change.

Is it possible via a query match table1.datetime & table2.datetime by HH:MM (ie. to the minute instead of to the second)?

View 1 Replies View Related

General :: Sed - Match Even Characters Only?

Sep 3, 2010

Say I had a string like so

Let's say I only wanted to grab TAC and BDX the ones in the 2nd, 4th, and 6th spot.

Will grab the lines from the rest of the file assuming these are the only lines with capital letters at the very beginning of each line.

Will delete the first 'T'. What I want to do is learn how to just pick the even characters, T(T)A(A)C(C) & B(B)D(D)X(X).

Is there something like the {1} which can pick just the even or odd character matches?

View 3 Replies View Related

General :: Sed Search To Match NOT Several Strings?

Nov 15, 2010

I am using sed to process an ascii tcpdump file whereby each packet is processed into a line with the same number of columns and useful information is pulled out like the time, packet type, length, and also IP addresses, payload type and port numbers where appropriate. The time is already changed to seconds, followed by the protocol over ethernet, such as IP, IP6, ARP etc. and I can change anything it detects as IP, IP6 and ARP into some other string, pulling out necessary information depending on the protocol and payload.The beginning part of the search for IP starts with the sed search /([0-9][0-9]*.[0-9][0-9]*)[ ]IP[ ,] ... /, where time is in seconds and ellipses means more stuff, and likewise for IP6 and ARP.But how do I process the lines that are NOT IP, IP6 or ARP? (Specifically NOT /IP[ ,]/, /IP6[ ,]/ or /ARP[ ,]/.) So that I can format them into a string with the same number of columns.

View 2 Replies View Related

General :: Making OS Match Hardware?

Jun 20, 2010

I have recently installed ubuntu 10.04 on my five year old desktop. Unfortunately, the official linux driver for my ATI X1600 card doesn't seem to support this ubuntu. There's an open source driver running now, but 3D applications run much slower than originally under windows. (which I can't seem to install on my sata raid harddisk anymore)

It's even so slow that I can't use those 3D applications anymore. I came to the conclusion that my computer is just too old for such a modern system as ubuntu 10.04. So I started looking for another version of linux. I tried the Linux Distribution Chooser, it pointed me at OpenSUSE 11.2. But I don't know, this program still looks kind of new. Too new for my computer.

I think that my computer needs an older version of linux, so that all the hardware will work properly. So I'd like to know if there's an older version of ubuntu/linux that still supports my hardware.

My computer was assembled from the following parts:
- DVDI LiteOn 16x/48x IDE bulk
- RAM 512 MB DDR/400 PC3200 ValueSelect
- HDDI 200GB 7200 Maxtor 6B200M0 8MB/SATA
- MB MSI k8T Neo2-F Athlon 64/939/DDR
- CPU AMD Athlon 64 3200+ 2.0Ghz/so939 BOX
- X GRA Sapphire R9600XT TV/DVI 256MB L-re

Does anyone know any distributions that fit this hardware? Some older versions of ubuntu perhaps? Something that allows me to install drivers that make 3D applications run a t normal speed? If someone knows about a Distribution Chooser that takes hardware into account, I'd also like to know.

View 1 Replies View Related

General :: Match A File Name Without Extension In Csh?

Aug 8, 2011

#!/bin/csh -f
source /xxxx/
set $spicedir = `sim_${1%.*}`
printf "Output folder is %s
" $spicedir
toolcommand -i $1 -o $spicedir
(-o output directory, -i =input)

I got spicedir: Undefined variable in my xterm

How could I match a file name without extension in csh

View 1 Replies View Related

General :: Use Grep To Match Domain Names?

Jan 10, 2011

I have a list of urls like code...

How can I use grep to match the domain names only?

All the urls have a / after the domain. And there are a lot of tlds, not sure how many, the list is quite big.

View 3 Replies View Related

General :: Partitions Do Not Match The Way Configured Them At Install?

Oct 24, 2010

On my last install I put Drive one windows on the first partioncreated a swap partitionlinux on the third partion rive twoLinux on the first partiton Grub found an old windows and made a menu for it So why does sfdisk -l return this? Code: Disk /dev/hda: 19457 cylinders, 255 heads, 63 sectors/trackUnits = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/hda1 * 0+ 2549 2550- 20482843+ 7 HPFS/NTFS
/dev/hda2 2550 10388 7839 62966767+ 5 Extended

[code]....

View 9 Replies View Related

General :: Get Files That Match ALL Patterns (using Grep)?

Jun 9, 2010

I want to traverse a directory and get a list of files that contain a set of patterns. I assumed I could use grep for this, but I having trouble getting grep to only return files that match ALL patterns. Here's what I've come up with so far:

Code:

grep --recursive --file=searchpatterns.txt --files-with-matches somedirectory/*

However, this gives me a list of files that match ANY of the patterns in the searchpatterns.txt file. I want to match ALL of the patterns. I've looked through the man page, but can't find anything that allows me to change the "OR" to "AND" for multiple patterns.

View 5 Replies View Related

General :: Sed Regex To Match Words Via A Pattern

Oct 24, 2010

I have some lines of text and I want to detect words that meet some criteria with sed.

E.g. The line "tetris cat dog test cactus stereotype"

I want to detect the word that contains two (2) ore more t letters. That mean the words tetris, test and stereotype.

The following regex doesn't do the job because it can;t distinguish words very well.

I thinks I have ti incorporate something like [^ ] in the regex but I wasn't successful...

View 3 Replies View Related

General :: Sed Remove String Until Final Match?

Mar 20, 2010

I have been fighting with a sed statement trying to get it to remove everything in a string until the last match and have been failing badly. how to get this to work..

sed --> enterprises.9.9.171.1.5.2.1.1.5
returns 5

I want sed to strip everything out until the last period. The final digit can and will change. Some parts before the final period can change as well, since enterprises will sometimes also be represented as more numbers and periods.

View 6 Replies View Related

General :: Statistic Match Module For Iptables

Feb 17, 2011

I have iptables 1.3.5 on CentOS 5.5 32 bits. kernel 2.6.18

How to install statistic match module for iptables?

View 3 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 :: No Fonts Match '9x15' When Starting Emacs?

Apr 7, 2010

I get the message

No fonts match '9x15'

when trying to run emacs and a linux box. I messed something up a while back, but I do not know how to fix this issue.

View 2 Replies View Related

General :: Regular Expressions Match 2 File Names?

Nov 20, 2010

How can we do a simple match by regular expressions on two filenames. I plan to use it in the command 'find -regex'

Code:
hosts.txt
ipaddress.txt

View 4 Replies View Related

General :: Replace Content Of One Column To Another If Match Found?

Dec 22, 2010

I have two files one having some transaction IDs only and sample content as follows:

Code:
SDP-DM-100755485
SDP-DM-100755504
SDP-DM-100755508
SDP-DM-100755716

[Code]....

View 5 Replies View Related

General :: Use Sed In Bash To Match Pattern Contained In 2 Lines?

Mar 14, 2011

I have a file called test. It has the following contents.Code:there youI want the output to be.Code:replaced youI am trying to use the sed command to replace every occurance of "hey newline there" with "replaced". I tried the following naive apporach.Code:sed 's/heythere/replace/' testThis gives a result containing the same data as the test file.

View 3 Replies View Related

General :: Windows - Match Hard Disk Partition Table?

Mar 15, 2010

What is the most efficient way to match the partition tables on two different hard disks?

I have saved the partition tables using dd command in linux.

The partition tables are from a Windows system.

View 1 Replies View Related

General :: Check If Any Of The Parameters To A Bash Script Match A String?

Sep 8, 2010

I'm trying to write a script where I want to check if any of the parameters passed to a bash script match a string. The way I have it setup right now is if [ "$3" != "-disCopperBld" -a "$4" != "-disCopperBld" -a "$5" != "-disCopperBld" -a "$6" != "-disCopperBld"]but there might be a large number of parameters, so I was wondering if there is a better way to do this?EDIT:I tried this chunk of code out, and called the script with the option, -disableVenusBld, but it still prints out "Starting build". Am I doing something wrong?

while [ $# -ne 0 ]
do
arg="$1"

[code]....

View 3 Replies View Related

General :: Perform Action When Clipboard Contents Match Regex?

May 20, 2011

I use the Actions feature of KDE's Klipper utility to run certain commands when I copy something into the clipboard that matches a particular regular expression. Unfortunately, I have to turn on Enable Clipboard Actions and select the command from a menu every time I copy something that I want to run the command on. I'd like to have that command run automatically instead.

You'd think this was possible, as there is an automatic checkbox in the action settings dialog box:

Unfortunately, that appears to do nothing. The documentation included with Klipper does not indicate what that checkbox is supposed to do.

Is it possible to configure Klipper to run a command automatically if the contents of the clipboard matches a regular expression? If not, is there another way to accomplish this?

View 1 Replies View Related

General :: Regular Expression To Match Unspecified Number Of Characters Until A '>'?

Jul 7, 2010

I'm attempting to search through a rather large assortment of html files created in Word using 'save as html'. what I'm trying to do is find and delete these tags (they're causing browsers to display black diamonds with white question marks):

<span style='mso-spacerun:yes'> </span> Tags contain from 1 to 4 spaces between opening and closing. I get positive results from this:

grep <span style='mso-spacerun:yes'> filename.html but once I attempt to tell it to match any number of characters up until the next '>' symbol, it tells me I'm using an invalid regex: grep <span style='mso-spacerun:yes'>[^>]+> filename.html

I've been nose-deep in regex tutorials for the past day or so, and I'm still not understanding why this doesn't work. If I put the pattern (without backslashes) into a separate file and use `grep -f patternfile filename.html`, I get no error but no matches either. So far as I can figure, the above regex boils down to:
Match the string "<span style='mso-spacerun:yes'>", followed by any number of characters that are not a ">", followed by a ">". If someone could tell me where I'm going wrong with this,

View 7 Replies View Related

General :: Command To Run Program When Package Doesn't Match Binary?

Jul 11, 2011

I have a weird/stupid question. How do you know what command would start an application after installing it, if the synaptic package name doesn't match?

For example google chrome and lmsensors. The first appears as Chrome in Synaptic and the second as lmsensors, but to run them you have to type google-chrome for the first and sensors for the second in the console to start them.
When I did locate sensors or locate chrome/chromium, nothing came up in the search that would hint me that I need to run those commands. I had to rely on a google search and look for someone else's answer. Is there a better way, one that I can figure it out on my own?

View 2 Replies View Related

General :: Easy Way To Find Out Like Which Items Don't Match Between 2 Files Regardless Of Order

Mar 15, 2011

I have following 2 files

File1
10.1.1.1
10.1.2.1
10.1.3.1

File2
10.1.3.1
10.1.2.1
10.1.1.1

Both are reverse of each other. Now, basically if you see, the contents are same, but in different order. Is there any easy way in which i can find out like which items dont match between 2 files, regardless of order. Lets say i add 10.1.4.1 to File1. Now the result of such comparison should be only '10.1.4.1'. Currently if i am comparing both files using diff, it gives me all the lines.

View 2 Replies View Related

General :: Installing VSFTPD And Configuring IPTables To Match Another Server?

Nov 11, 2009

I've been tasked with setting up a RHEL FTP server to mirror one we currently have. From what I've read, I need to install and configure VSFTPD and then configure IPTables. From what I've been able to come up with, I need to follow the steps in this article to install and setup VSFTPD. Is this a good complete article to follow you think?Also, how do I copy the iptables config from that server to my new one? I think that iptables on our current server only allows certain IPs or blocks certain IPs (not sure which), so I need to have it do that on my new server as well

View 14 Replies View Related

General :: Regular Expression For Mod Rewrite - Match Directories Ape/ And Apes/

Dec 13, 2010

I have this..

RewriteRule ^(apes|ape)/(.*)$ $2?fh=$1 [L,QSA]

I only want to match the directories ape/ and apes/ but I think it is matching any directory that ends in "ape" or "apes" or maybe does it match any string containing those characters in any order? I am not great at regex, and have read alot, but still not sure if I understand this correctly.

View 2 Replies View Related

Ubuntu :: Change Delete Button To Delete Instead Of Move To Trash

Apr 18, 2010

Instead of moving to trash, how can i make the delete button delete? Delete is already enabled on the right click menu.

View 7 Replies View Related

Ubuntu :: Folder Wont Delete \ Whenever Try To Press Delete Noting Happens?

May 9, 2010

SO after using Testdisk to recover some images, the folders recup_dir.1 & 2 have saved in my FIle System area, when ever I try to press delete noting happens. I have also tried rm -f -rrm -f -fIt still dont delete, I have also deleted my user account and made a new one, but the files are still there.

View 4 Replies View Related







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