Sponsored Content
Top Forums Shell Programming and Scripting Delete blocks of lines from text file Post 302152244 by summer_cherry on Wednesday 19th of December 2007 05:17:13 AM
Old 12-19-2007
awk

Hi,
Please try follow one.

One concern, i am not sure what will be content of all your blah blah. If they will cover all the content, maybe will cause some conflict with the code. Anyway, please try it, if any problem, please post it. Maybe all of us here can help you to solve it.

code:
Code:
sed '/^$/d' a > a.tmp
nawk 'BEGIN{
FS="\r"
RS="}\r"
a="abc"
b="pqr"
}
{
if ($1=="" && index($2,a)==0 && index($2,b)==0)
	print $0
if ($1!="" && index($1,a)==0 && index($1,b)==0)
	print $0
}' a.tmp
rm a.tmp

 

10 More Discussions You Might Find Interesting

1. Programming

Delete specific lines in a text file

Hi, experts, I would like to create a function that can calculate the total number of lines in a saved text file and delete specific lines in that particular file (I only want the last few lines). Hav anybody have the experience and giv me a hand in this? (9 Replies)
Discussion started by: dniz
9 Replies

2. Shell Programming and Scripting

Delete Blank Lines Between DHCP Host Blocks

Hi All, I have a dhcpd.conf file that gets static hosts added and removed via a shell script. After sometime, there becomes huge gaps of space ( blank lines ) between each host block. I tried a couple of sed one-liners; but, I can't seem to get the output I'm looking for. Also, I would like... (4 Replies)
Discussion started by: cstovall
4 Replies

3. Shell Programming and Scripting

extract blocks of text from a file

Hi, This is part of a large text file I need to separate out. I'd like some help to build a shell script that will extract the text between sets of dashed lines, write that to a new file using the whole or part of the first text string as the new file name, then move on to the next one and... (7 Replies)
Discussion started by: cajunfries
7 Replies

4. UNIX for Dummies Questions & Answers

Delete vertical lines in an text file

Hi everybody! I need to delete several vertical lines in a huge text file. It should work like the example below. Delete the vertical lines 2 and 8. 123456789 masldfjla afsajfwel sajfljsaf safsarfrl sajfeljwq 1345679 msldfja asajfwl sjfljsf sfsarfl sjfeljq Is there a... (11 Replies)
Discussion started by: relaxo
11 Replies

5. Shell Programming and Scripting

looking for a script that will delete lines in a text file

it will grep for a line and then delete these line. how do i begin to write this script if theres no available one? (3 Replies)
Discussion started by: garfish
3 Replies

6. Shell Programming and Scripting

How to delete lines from text file?

hi guys, I have very large txt files (200GB) and just want to to delete the first two lines (headers). So far I used sed -i '1,2d' infile.txtbut this command always takes extremely long as it writes all again. Is there a better way to do it (ie just to delete the lines without writing all... (2 Replies)
Discussion started by: TuAd
2 Replies

7. Shell Programming and Scripting

How to delete lines of a text file based on another text file?

I have 2 TXT files with with 8 columns in them(tab separated). First file has 2000 entries whereas 2nd file has 300 entries. The first file has ALL the lines of second file. Now I need to remove those 300 lines (which are in both files) from first file so that first file's line count become... (2 Replies)
Discussion started by: prvnrk
2 Replies

8. Shell Programming and Scripting

How to remove duplicate text blocks from a file?

Hi All I have a list of files which will have duplicate list of blocks of text. Following is a sample of the file, I have removed the sensitive information from the file. All the code samples starts from <TR BGCOLOR="white"> and Ends with IP address and two html tags like this. 10.14.22.22... (3 Replies)
Discussion started by: mahasona
3 Replies

9. Shell Programming and Scripting

Delete all CONSECUTIVE text lines from file shell scripting

Hi I have a text file like below. THe content of the text will vary. Entire text file have four consecutive lines followed with blank line. I want to delete the occurrence of the two consicutive lines in the text file. I don't have pattern to match and delete. Just i need to delete all... (5 Replies)
Discussion started by: RJSKR28
5 Replies

10. Shell Programming and Scripting

Tried many options but unable to delete blank lines from text file

Hi, I tried the following options but was unable to delete blank lines from file Input file = temp.hash.txt temp.hash.txt content 90 0 89.56 0 0 57575.4544 56.89 (9 Replies)
Discussion started by: uuuunnnn
9 Replies
hiutil(1)						    BSD General Commands Manual 						 hiutil(1)

NAME
hiutil -- utility for creating and examining Help Viewer indices SYNOPSIS
hiutil -Cf file [-1agv] [-m NUM] [-s LANG | PATH] [-r URL] [-t EXT] dir hiutil [-ADEFMRS] -f file DESCRIPTION
hiutil is for creating and examining .helpindex files. These files were historically created by Help Indexer.app, which now calls this tool. There are several different (and mutually-exclusive) modes: -C, --create Create an index file at the location you specify. You must provide both a directory of HTML files to index and path to an output file, which will be overwritten if it exists. -A, --list-anchors List the index's anchors separated by newlines. -D, --list-anchor-dictionary List the index's anchor dictionary in XML. This includes a list of which files contain each anchor. -E, --list-index-versions List the index's version dictionary in XML. It describes the system environment on which the index was created. -F, --list-files List all the files included in the index, separated by newlines. You can use the -v option with this mode to get titles and descrip- tions as well. -H, --help Prints out usage data. -M, --list-min-term-length List the index's minimum term length. -R, --list-remote-url List the index's remote URL. (This is only relevant for old-style indexes which include one.) -S, --list-stopwords List the index's stopwords separated by newlines. -V, --version Prints out the version of the tool. GENERAL OPTIONS
These can be used with any mode. -f, --file P ass in the path to a file, either one to be created or one to be examined. -v, --verbose Verbose output. Errors are always shown, but passing this argument once will print out warnings too. Twice will print out errors, warnings and progress notes. This can be a lot of data! CREATE OPTIONS
These can only be used with the create mode. -1 Index one file at a time. The default is to use a queue to index several files in parallel. In combination with -vvv, this option can be useful in determining which file an error message is from. -a, --anchors Index anchors. The default is not to. Without this flag, there will be no anchor dictionary in the index. -e, --exclude=PATTERN Exclude files which match this pattern. Uses NSPredicate's MATCHES comparison method on the file's path relative to the directory being indexed. This option can be passed as many times as necessary, once per pattern. Exclusions take precedence over files included with -i. -g, --generate-summaries Generate summary text. This can be slow, but is useful if you don't have DESCRIPTION meta tags on some pages. -i, --include=PATTERN Include files which match this pattern. Uses NSPredicate's MATCHES comparison method on the file's path relative to the directory being indexed. The default patterns to index are ".htm" and ".html". If these defaults are undesirable, you may use -e above to exclude them. This option can be passed as many times as necessary, once per pattern. -m, --min-term-length=NUM Minimum term length. Can be 1, 2 or 3. This is the number of consecutive tokens (typically a character) required for a term not to be ignored by the indexer. Recommended values are 3 for English and 1 for Chinese and other ideographic languages. -s, --stopwords=LANG|PATH Use stopwords. If you have your own stopwords .plist, provide that path. Otherwise, pass the two-character language code: en English es Spanish de German fr French hu Hungarian it Italian sv Swedish -r, --remote-url=URL Include a remote URL with the index. This is only useful in Type 1 or Type 2 help books, because the URL is in the help bundle's Info.plist for Type 3 books. The URL should be fully qualified, for example: -l, --locale=LANG Index for a specific locale. Instead of having to boot into the locale to index, pass the language code or locale identifier here to index for that language. Example locale identifiers: en_US US English es_ES Spanish de German fr French hu Hungarian ru_RU Russian https://www.mycompany.com/help_v1/ FILES
/usr/share/hiutil/Stopwords.plist List of default stopwords in different languages EXAMPLES
Here's what you'll mostly use this tool for, creating a help index: hiutil -Caf /tmp/myhelp.helpindex myHelpDirectory And if you then want to make sure that worked as expected: hiutil -Af /tmp/myhelp.helpindex Here's how to index .xml files as well, while ignoring everything in the idx directory in the root of your help folder: hiutil -Caf /tmp/help.helpindex -i ".*.xml$" -e "idx/.*" myhelpdir NOTES
hiutil requires Mac OS X 10.6 or greater. Darwin June 2, 2019 Darwin
All times are GMT -4. The time now is 06:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy