Sponsored Content
Top Forums Shell Programming and Scripting Using sed to delete a line having a particular keyword Post 302446946 by ajincoep on Friday 20th of August 2010 08:32:46 AM
Old 08-20-2010
Using sed to delete a line having a particular keyword

Hi Geeks Smilie,
I need to delete a line from file that contains a particular keyword.
I had read in some forum of unix.com that below code could be used

Code:
sed "/$titlesearch/d" movielist >tmp
mv tmp movielist

But my file contains lines which contain slashes (/)
FOr eg:
/etc/movie/title/
/etc/movie2/tiltle2/

$titlesearch is a variable that contains any of the above line to delete

But when I execute it gives me error like
Unrecognized command: /etc/movie/title//d

I think it is happening because of slashes Smilie Please suggest
Thanks in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed: delete regex line and next line if blank

Hi, I want to write a sed script which from batiato: batiato/giubbe: pip_b.2.txt pip_b.3.txt pip_b.3mmm.txt bennato: bennato/peterpan: 123.txt consoli: pip_a.12.txt daniele: (2 Replies)
Discussion started by: one71
2 Replies

2. Shell Programming and Scripting

How can i delete a keyword starting with x in unix

I am trying to delete key word starting with x in a unix text file. example, I am trying to delete the words like xaa,xabxbb,xbd and so on.... my input file is some thing like this xaaa w 1234 5678 rwsd ravi xw123 xbc3 ohrd want to delete words xaaa,xw123 and xbc3 from the above... (10 Replies)
Discussion started by: rdhanek
10 Replies

3. Shell Programming and Scripting

Delete the lines after the last instance of the keyword

I have my input sometyhing like this aaa bbbbbb cccccc ddddd eeeee 1234 ravi kumar aaaaaa vvvvvvv 5678 ravi kumar rrrrrrr mmmmmmm I want the output as follows. aaa bbbbbb cccccc ddddd eeeee 1234 ravi kumar aaaaaa vvvvvvv 5678 ravi kumar (2 Replies)
Discussion started by: rdhanek
2 Replies

4. Shell Programming and Scripting

Delete the lines before the first instance of the keyword

I have my data something like this. I want to delete all the lines before the frist instance of the key word 'ravi kumar' aaa bbbbbb cccccc ddddd eeeee 1234 ravi kumar aaaaaa vvvvvvv 5678 ravi kumar rrrrrrr mmmmmmm I want the output as follows. 1234 ravi kumar aaaaaa... (8 Replies)
Discussion started by: rdhanek
8 Replies

5. Shell Programming and Scripting

search for keyword in subsequent lines and delete the second line

I have my data something like this I need to search for the keyword yyyy in the susequent lines and if it is present, delete the second line with keyword. In other words, if a keywords is found in two subsequent lines delete the second line. input data: aaaa bbbbb cccc dddd xxxx... (4 Replies)
Discussion started by: rdhanek
4 Replies

6. Shell Programming and Scripting

How can i delete a keyword containing XYZ in unix

Hi all, I am trying to remove the words which has XYZ as a prt of that. My input file is something like this : PHNDAZLF-UPS-XYZ' aaaaaaa bbbbb ADFRTEJKS-XYZ cccccccc ddddddd rrrrrr SGETHEHDJ-ABC-RXY' hhhhh ttttt' kkkk FHJSKSJDKD-XXX-YYY Output expected is : aaaaaaa... (7 Replies)
Discussion started by: rdhanek
7 Replies

7. Shell Programming and Scripting

USING sed to delete a line

Please let me know wat would be sed command to delete any partcular line from a file and also moving lines below it to up. ie wen line #9 is deleted data in line #10 should move to #9 and so on. (2 Replies)
Discussion started by: fidelis
2 Replies

8. Shell Programming and Scripting

Sed or Grep to delete line containing patter plus extra line

I'm new to using sed and grep commands, but have found them extremely useful. However I am having a hard time figuring this one out: Delete every line containing the word CEN and the next line as well. ie. test.txt blue 324 CEN green red blue 324 CEN green red blue to produce:... (2 Replies)
Discussion started by: rocketman88
2 Replies

9. Shell Programming and Scripting

sed command to grep multiple pattern present in single line and delete that line

here is what i want to achieve.. i have a file with below contents cat fileName blah blah blah . .DROP this REJECT that . --sport 7800 -j REJECT --reject-with icmp-port-unreachable --dport 7800 -j REJECT --reject-with icmp-port-unreachable . . . more blah blah blah --dport 3306... (14 Replies)
Discussion started by: vivek d r
14 Replies

10. Shell Programming and Scripting

Search for a Keyword in file and replace another keyword or add at the end of line

Hi I want to implement something like this: if( keyword1 exists) then check if(keyword2 exists in the same line) then replace keyword 2 with New_Keyword else Add New_Keyword at the end of line end if eg: Check for Keyword JUNGLE and add/replace... (7 Replies)
Discussion started by: dashing201
7 Replies
TV_IMDB(1p)						User Contributed Perl Documentation					       TV_IMDB(1p)

NAME
tv_imdb - Augment XMLTV listings files with imdb.com data. SYNOPSIS
tv_imdb --imdbdir <dir> [--help] [--quiet] [--download] [--prepStage (1-7,all)] tv_imdb --imdbdir <dir> [--help] [--quiet] [--movies-only][--stats][--output FILE] [FILE...] DESCRIPTION
Very similar to tv_cat in symantics (see tv_cat) except whenever a programme appears with "date" entry the title and date are used to look up extra data by using the XMLTV::IMDB package. --output FILE write to FILE rather than standard output --quiet disable all status messages (that normally appear on stderr). --download try to download data files if they are missing (in --prepStage). --stats force output of grab stats (stats output disabled in --quiet mode). --movies-only only augment programs that look like movie listings (4 digit 'date' field). All programs are checked against imdb.com data (unless --movies-only is used). For the purposes of tv_imdb, an "exact" match is defined as a case insensitive match gainst imdb.com data (which may or may not include the transformation of '&' to 'and' and vise-versa. If the program includes a 4 digit 'date' field the following is matches are attempted, the first succeeding match is used: 1. an "exact" title/year match against movie titles is done 2. an "exact" title match against tv series (and tv mini series) 3. an "exact" title match against movie titles with production dates within 2 years of the 'date' value. Unless --movies-only is used, if the program does not include a 4 digit 'date' field the following matches are attempted, the first succeeding match is used: 1. an "exact" title match against tv series (and tv mini series) When a match is found in the imdb.com data the following is applied: 1. the 'title' field is set to match exactly the title from the imdb.com data. This includes modification of the case to match and any transformations mentioned above. 2. if the match is a movie, the 'date' field is set to imdb.com 4 digit year of production. 3. the type of match found (Movie, TV Movie, Video Movie, TV Series, or TV Mini Series) is placed in the 'categories' field. 4. the url to the www.imdb.com page is added 5. the director is added if the match was a movie or if only one director is listed in the imdb.com data (because some tv series have > 30 directors) 6. the top 3 billing actors are added. 7. genres added to 'categories' field (current list of genres are Short, Drama, Comedy, Documentary, Animation, Adult, Action, Family, Romance, Crime, Thriller, Musical, Adventure, Western, Horror, Sci-Fi, Fantasy, Mystery, War, Film-Noir, Music 8. imdb user ratings added to 'star-ratings' field. HOWTO In order to use tv_imdb, you need: 1. choose a directory location to use for the tv_imdb database (you'll need about 1/2 GB of free space), 2a. run 'tv_imdb --imdbdir <dir> --prepStage all --download' to download the list files from imdb.com. Or, 2b If you have a slow network connection you may prefer to omit the '--download' flag and be prompted for what you need to download by hand. See <http://www.imdb.com/interfaces> for the download sites. Then once you have the files rerun without '--download'. Note: '--prepStage' sucks a bit of memeory, but you can run each prepStage separately by running --prepStage with each of the stages (see --help for details). 3. Once you have the database loaded try 'cat tv.xml | tv_imdb --imdbdir <dir> > tv1.xml'. Feel free to report any problems with these steps to xmltv-devel@lists.sf.net. BUGS
The '--prepStage' needs a lot of memory to run at a reasonable speed, over 200 megabytes with the current imdb data files. For there to be 200 megabytes free for tv_imdb, the system will need at least 256 megabytes of RAM. Running with less can take hours (or days!) - although fortunately this stage needs to be run only once after downloading the data files. Could use a --configure step just like the grabbers so you do not have to specify the --imdbdir on the command line every time. Also this could step you through the prep stages with more description of what is being done and what is required. Configure could also control the number of actors to add (since some movies have an awful lot), currently we are adding the top 3. How and what to look up needs to be option driven. Needs some more controls for fine tuning "close" matches. For instance, currently it looks like the North America grabber only has date entries for movies, but the imdb.com data contains made for video movies as well as as real movies, ot is it's possible to get the wrong data to be inserted. In this case we may want to say "ignore tv series" and "ignore tv mini series". Along with this, we'd want to define what a "close" match is. For instance does a movie by the same title with a date out by 1 year or 2 years considered a match (currently we're using 2). Nice to haves include: verification/addition of programe MPAA/VCHIP ratings, addition of imdb.com user ratings (by votes) to programes. Potenially we could expand to include "country of origin", "description", "writer" and "producer" credits, maybe even "commentator". Heh, if the XMLTV.dtd supported it, we could even include urls to head shots of the actors :) SEE ALSO
xmltv(5) AUTHOR
Jerry Veldhuis, jerry@matilda.com perl v5.14.2 2011-06-22 TV_IMDB(1p)
All times are GMT -4. The time now is 11:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy