Sponsored Content
Full Discussion: sed delete range
Top Forums Shell Programming and Scripting sed delete range Post 302520613 by mirni on Sunday 8th of May 2011 05:26:19 PM
Old 05-08-2011
You mean you want to delete the link, defined between '<a href' and '</a>' tags, right? Use sed's 's' command (substitute)
Here:
Code:
$ echo 'aqua>Stroomprobleem in Hengelo verholpen <a href="107-01.html"><font color=yellow>107</a>' | sed 's!<a href.*</a>!!'
aqua>Stroomprobleem in Hengelo verholpen

The exclamation marks are delimiters, and any char will do, as long as there is exactly three of them there.
Beware, however, that pattern matching is greedy; so if you happen to have more links on one line, it will eat up everything between the first '<a href' and the last '</a>':
Code:
$ echo 'Beginning<a href="whatevah">link1</a>This is eaten too<a href="again">link2</a>end of line' | sed 's!<a href.*</a>!!'
Beginningend of line

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed Range Issue

OK, so for a grand overview of what I'm trying to do: I've got 2 files that are mostly like. The file format is: data data data data data data data data data data (2 Replies)
Discussion started by: Wrathe
2 Replies

2. Shell Programming and Scripting

Sed Range command

Hi, I am trying to get all the log entries in a log file based on start and end times, I have tried to use the following but couldnt get the desired output: sed -n '/start/,/end/ p' file & newtime=`echo "$time" | cut -d -start | cut -d" " -start` Kindly help me, Thanks (0 Replies)
Discussion started by: openspark
0 Replies

3. Shell Programming and Scripting

sed pattern range

Hi guys, trying to replace a '#' with a ' ' (space) but only between the brackets '(' and ')' N="text1#text2#text3(var1#var2#var3)" N=`echo $N |sed '/(/,/) s/#. //'` echo $N Looking for an output of "text1#text2#text3(var1 var2 var3)" Any ideas? (15 Replies)
Discussion started by: mikepegg
15 Replies

4. Shell Programming and Scripting

Grep a string in a range and delete the line

Hi, i need to delete a lines after searching a particular string but this searching should only happen after the 4th line.. basically imagine a file like this From: abcd.yahoo.com To: cdeb.yahoo.com Subject: hi all sdfsd sadasd asdasd dfsdf From: abcd.yahoo.com To:... (3 Replies)
Discussion started by: depakjan
3 Replies

5. Shell Programming and Scripting

delete rows between closest pattern or range

Hi I am having some problom deleting the lines between two specific lines in a file. need to delete lines between two closest lines. i.e need to find the closest range or pattern in a file with repeating patterns. Sample Input: WARNING <some text in n number of lines> ERROR:2597... (10 Replies)
Discussion started by: sudheer1984
10 Replies

6. UNIX for Dummies Questions & Answers

Date range command (and delete)

Hello. Newbie here.... I basically have a directory with tens of thousands (literally) subdirectories and need to delete those that are older than 2008 (hundreds) with all their contents. I've looked through all the RM parameters and still can't quite figure out how to specify the data range... (7 Replies)
Discussion started by: pqmomba8
7 Replies

7. Shell Programming and Scripting

how to use sed to get 2nd range?

Hi all, Is there a way to use the sed command to get the second range? For instance: sample.dat: ------------- 11111 22222 33333 44444 ------------- using "sed -n '/^ping/,/^$/p' sample.dat can get the first 2 lines. But is there a way to get the first 4 lines, from... (4 Replies)
Discussion started by: sleepy_11
4 Replies

8. Shell Programming and Scripting

Delete lines falling in a range

Hi All, I have a file which contains lakhs of records 0136812368126 03000 Statement 1237129372189 02321 JIT 0136812368126 05000 terminal 1237129372189 05001 Utilise Is there an option to delete all lines which fall within the range 05000 to 05999? I tried... (6 Replies)
Discussion started by: swasid
6 Replies

9. UNIX for Beginners Questions & Answers

How to delete row in csv file on date range?

I want to delete row in csv file , which row value from 2009-10-01 to 2011-06-03 using script.my csv row data look like: 2009-10-01 2011-03-30 2011-03-31 2011-04-01 2011-06-03 2011-06-30 2011-07-01 2011-09-28 ... (7 Replies)
Discussion started by: rakibul639
7 Replies

10. UNIX for Beginners Questions & Answers

Sed/awk to delete a regex between range of lines

Hi Guys I am looking for a solution to one problem to remove parentheses in a range of lines. Input file module bist_logic_inst(a, ab , dhd, dhdh , djdj, hdh, djjd, jdj, dhd, dhp, dk ); input a; input ab; input dhd; input djdj; input dhd; output hdh; output djjd; output jdj;... (5 Replies)
Discussion started by: kshitij
5 Replies
ln(1)							      General Commands Manual							     ln(1)

Name
       ln - link to a file

Syntax
       ln [ -f ] [ -i ] [ -s ] name1 [name2]
       ln [ -f ] [ -i ] [ -s ] name ... directory

Description
       A  link is a directory entry referring to a file.  A file, together with its size and all its protection information may have several links
       to it.  There are two kinds of links: hard links and symbolic links.

       By default makes hard links.  A hard link to a file is indistinguishable from the original directory entry.  Any  changes  to  a  file  are
       effective independent of the name used to reference the file.  Hard links may not span file systems and may not refer to directories.

       Given  one or two arguments, creates a link to an existing file name1.  If name2 is given, the link has that name.  The name2 may also be a
       directory in which to place the link.  Otherwise it is placed in the current directory.	If only the directory is specified,  the  link	is
       made to the last component of name1.

       Given  more  than two arguments, makes links to all the named files in the named directory.  The links made have the same name as the files
       being linked to.

Options
       -f   Forces existing destination pathnames to be removed before linking without prompting for confirmation.

       -i   Write a prompt to standard output requesting information for each link that would overwrite an existing file.  If  the  response  from
	    standard input is affirmative, and if permissions allow, the link is done. The -i option has this effect even if the standard input is
	    not a terminal.

       -s   Creates a symbolic link.

	    A symbolic link contains the name of the file to which it is linked.  The referenced file is used when an operation  is  performed	on
	    the  link.	 A  on a symbolic link returns the linked-to file.  An must be done to obtain information about the link.  The call may be
	    used to read the contents of a symbolic link.  Symbolic links may span file systems and may refer to directories.

See Also
       cp(1), mv(1), rm(1), link(2), readlink(2), stat(2), symlink(2)

																	     ln(1)
All times are GMT -4. The time now is 03:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy