Sponsored Content
Full Discussion: sed match exactly and delete
Top Forums Shell Programming and Scripting sed match exactly and delete Post 302935604 by anil510 on Wednesday 18th of February 2015 05:13:01 AM
Old 02-18-2015
sed match exactly and delete

I am using following sed rule to delete 2 lines after a pattern match inclusive.

Code:
[root@server ~]# cat /tmp/temp.txt
dns.com
11
22
mydns.com
11
22
dns.com.au
11
22
LAST LINE
[root@server ~]# cat  /tmp/temp.txt | sed -e '/dns.com/,+2d'

LAST LINE

I just need to remove lines below dns.com only and NOT below other domains. The rule I am using deletes lines below mydns.com and dns.com.au
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to delete lines do NOT match a pattern

On Unix, it is easy to get those lines that match a pattern, by grep pattern file or those lines that do not, by grep -v pattern file but I am editing a file on Windows with Ultraedit. Ultraedit support regular expression based search and replace. I can delete all the lines that match a... (1 Reply)
Discussion started by: JumboGeng
1 Replies

2. Shell Programming and Scripting

SED: match pattern & delete matched lines

Hi all, I have the following data in a file x.csv: > ,this is some text here > ,,,,,,,,,,,,,,,,2006/11/16,0.23 > ,,,,,,,,,,,,,,,,2006/12/16,0.88 < ,,,,,,,,,,,,,,,,this shouldnt be deleted I need to use SED to match anything with a > in the line and delete that line, can someone help... (7 Replies)
Discussion started by: not4google
7 Replies

3. Shell Programming and Scripting

sed: find match and delete the line above

I am searching a dhcpd.conf to find the hardware ethernet match, then once the match is found delete just the line above it. For example: testmachine.example { hardware ethernet 00:00:00:00:00:00; fixed address 192.168.1.100; next-server 192.168.1.101; filename "linux-install/pxelinux.0"; }... (3 Replies)
Discussion started by: cstovall
3 Replies

4. Shell Programming and Scripting

Sed to delete exactly match pattern and print them in other file

Hi there, I need help about using sed. Iam using sed to delete and print lines that match the port number as listed in sedfile. I am using -d and -p command for delete match port and print them respectively. However, the output is not synchonize where the total deleted lines is not similar with... (3 Replies)
Discussion started by: new_buddy
3 Replies

5. Shell Programming and Scripting

sed problem - delete all lines until a match on 2 lines

First of all, I know this can be more eassily done with perl or other scripting languages but, that's not the issue. I need this in sed. (or wander if it's possible ) I got a file (trace file to recreate the control file from oracle for the dba boys) which contains some lines another line... (11 Replies)
Discussion started by: plelie2
11 Replies

6. UNIX for Advanced & Expert Users

On Match Delete Field

Hi, A text file contains lines of fields seperated by some delimiter; space for example; some lines but not all will have in the second field a value like an inital (e.g., A. or B. or Jr.) for those lines with such a value in field 2, we wish to have that value deleted. We also wish to do this... (1 Reply)
Discussion started by: rfransix
1 Replies

7. Shell Programming and Scripting

Sed delete blank lines upto first pattern match

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. for example: Input output: I have got it to work within a range of two patterns with the following: sed '/1/,/pattern/{/^]*$/d}' The... (2 Replies)
Discussion started by: duonut
2 Replies

8. Shell Programming and Scripting

Delete the last line if match the string

Hi, How to delete the last line if is match the below string else no action... String checking "END OF FILE. ROW COUNT: " 9f680174-cb87-4f71-887a-93b6f62fa5aa|20077337254|2 9f680174-cb87-4f71-887a-93b6f62fa5aa|20077337254|0 229f680174-cb87-4f71-887a-93b6f62fa5aa|20077337254|3 END OF... (2 Replies)
Discussion started by: bmk
2 Replies

9. Ubuntu

Delete all files that match date '+%Y-%m-%d_%H:%M'

I need to modify this so it delete all date files and not leave the 2 newest. TARGET_DIR='/media/andy/MAXTOR_SDB1/Ubuntu_Mate_18.04/' REGEX='{4}-{2}-{2}_{2}:{2}' # regular expression that match to: date '+%Y-%m-%d_%H:%M' LATEST_FILE="$(ls "$TARGET_DIR" | egrep "^${REGEX}$" | tail -1)"... (4 Replies)
Discussion started by: drew77
4 Replies

10. UNIX for Beginners Questions & Answers

sed script to delete the last word after a last pattern match

Hi Guys , I am having a file as stated below File 1 sa0 -- i_core/i_core_apb/i_afe0_controller/U261/A sa0 -- i_core/i_core_apb/i_afe0_controller/U265/Z sa1 -- i_core/i_core_apb/i_afe0_controller/U265/A sa1 -- i_core/i_core_apb/i_afe0_controller/U268/Z sa1 -- ... (7 Replies)
Discussion started by: kshitij
7 Replies
dns(n)								 Tnm Tcl Extension							    dns(n)

__________________________________________________________________________________________________________________________________________________

NAME
dns - Query the Domain Name System of the Internet. _________________________________________________________________ DESCRIPTION
The dns command allows to query the Internet Domain Name System (DNS) (RFC 1034, RFC 1035, RFC 974, RFC 1912) for host information. The main purpose of this command is to convert host names into IP addresses and vice versa. The dns command also allows to retrieve host infor- mation records as well as mail exchanger records. DNS COMMAND
dns [options] Invoking the dns command with options but without any command arguments allows to retrieve and change the default values. See the description of supported options below. Default values are bound to a Tcl interpreter which allows to have multiple Tcl interpreter with different defaults. dns [options] address host The dns address command sends a query to retrieve the address record for the specified host. The command returns the list of IP addresses for the given host name. dns [options] name address The dns name command sends a query to retrieve the domain name pointer record. A pointer record maps an IP address to a fully quali- fied domain name (FQDN). The command returns the fully qualified domain name for the given IP address. dns [options] hinfo name The dns hinfo command sends a query to retrieve the host information record. The command returns a list containing two elements. The first element describes the hardware type and the second element the operating system. dns [options] mx name The dns mx command sends a query to retrieve the mail exchanger record. The command returns a list of mail exchanger records if name is a domain name for which one or more MX records exist. Each element of this list contains a full qualified domain name (FQDN) and its priority. dns [options] soa name The dns soa command sends a query to retrieve the start of authority record for a DNS domain. The command returns the name of the authoritative DNS server of the DNS domain name. DNS OPTIONS
-server server The -server option defines the DNS server which will be used to process the request. The default value is the default DNS server configured on the local system. -timeout time The -timeout option defines the time the dns command will wait for a response. The time is defined in seconds with a default of 2 seconds. -retries number The -retries option defines how many times a request is retransmitted during the timeout interval. The default number of retries is 2. Please note, that many resolver double the last timeout after every retry. SEE ALSO
scotty(1), Tnm(n), Tcl(n) AUTHORS
Erik Schoenfelder <schoenfr@gaertner.de> Juergen Schoenwaelder <schoenw@cs.utwente.nl> Tnm dns(n)
All times are GMT -4. The time now is 04:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy