Top Forums Shell Programming and Scripting Search and Remove Lines within File Post 302391428 by leepet01 on Monday 1st of February 2010 09:49:17 AM
Search and Remove Lines within File


I've searched through the scripting section but could not find what I need.

I need to search for empty sections within a file and remove them.

Here is an example file:
Title 123
Title 098
Title 567

I need to remove “Title 098” because it is empty, but keep sections and title header for “Title 123” & “Title 567”

So the output would be:

Title 123
Title 567

The "Title" is the common header of all sections from all inputed files. I use /bin/sh.

Any assistance would be GREATLY appreciative
Test Your Knowledge in Computers #503
Difficulty: Easy
The flow of control (or simply control flow) is how a program processes its instructions.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

different take on common ?: search for two strings and remove lines between them

Thank you for assisting, I've got a partial solution just needs a tweak. Hulk-BASH$ cat somefile.txt oh there is some stuff here some more stuff here START_LABEL stuff I want more stuff I want END_LABEL other stuff here too and even more stuff here too Hulk-BASH$ Hulk-BASH$ sed... (8 Replies)
Discussion started by: laser
8 Replies

2. UNIX for Dummies Questions & Answers

vi to remove lines in file

All, I have a text file with several entries like below: personname I know there is a way to use vi to remove only the line. Can someone help? I believe that it involves /s/g/ something...I just can't remember the exact syntax. Thanks (2 Replies)
Discussion started by: kjbaumann
2 Replies

3. Shell Programming and Scripting

remove lines from file

Hi gurus, i'm trying to remove a number of lines from a large file using the following command: sed '1,5000d' oldfile > newfile Somehow the lines in the old file are not deleted... Am I doing this wrongly? Any suggestions? :confused: Thanks! :) wee (10 Replies)
Discussion started by: lweegp
10 Replies

4. Shell Programming and Scripting

remove : lines from file

A small question I have a test.txt file I have contents as: a:google b:yahoo : c:facebook : d:hotmail How do I remove the line with : my output should be a:google b:yahoo c:facebook d:hotmail (5 Replies)
Discussion started by: aronmelon
5 Replies

5. Shell Programming and Scripting

Search and remove in a text file

Need help whit a script where I have to input a name and then remove a line where that name is in a file file ex: 001op;Name;Location;date 002op;Name;Location;date and so on.... can anybody help me??? thanks (4 Replies)
Discussion started by: nogame11
4 Replies

6. Shell Programming and Scripting

Search based on 1,2,4,5 columns and remove duplicates in the same file.

Hi, I am unable to search the duplicates in a file based on the 1st,2nd,4th,5th columns in a file and also remove the duplicates in the same file. Source filename: Filename.csv "1","ccc","information","5000","temp","concept","new" "1","ddd","information","6000","temp","concept","new"... (2 Replies)
Discussion started by: onesuri
2 Replies

7. Shell Programming and Scripting

Search and remove the lines

Hallo Team, Hope you are having a wonderful Friday. Here goes i am searching for a pattern and after finding the lines which contain this pattern i want to remove/delete them. This is my code: grep Originating BW*2013*|grep -v "ACCOUNT NOT FOUND"|grep -v "Unknown called number"|grep -v... (2 Replies)
Discussion started by: kekanap
2 Replies

8. Shell Programming and Scripting

How to search multiple patterns and remove lines from a file?

Hi, I have a file content as below. Table : PAYR Displayed fields: 15 of 15 Fixed columns: 4 List width 0999... (4 Replies)
Discussion started by: shirdi
4 Replies

9. UNIX for Dummies Questions & Answers

Want to remove all lines but not latest 50 lines from a file

Hi, I have a huge file which has Lacs of lines. File system got full. I want your guys help to suggest me a solution so that I can remove all lines from that file but not last 50,000 lines. I want solution which can remove lines from existing file so that I can have some space left with. (28 Replies)
Discussion started by: prashant2507198
28 Replies

10. Shell Programming and Scripting

Remove lines that are subsets of other lines in File

Hello everyone, Although it seems easy, I've been stuck with this problem for a moment now and I can't figure out a way to get it done. My problem is the following: I have a file where each line is a sequence of IP addresses, example : (5 Replies)
Discussion started by: MisterJellyBean
5 Replies
extract_font_range(3alleg4)					  Allegro manual				       extract_font_range(3alleg4)

extract_font_range - Extracts a range of characters from a font. Allegro game programming library. SYNOPSIS
#include <allegro.h> FONT *extract_font_range(FONT *f, int begin, int end) DESCRIPTION
This function extracts a character range from a font and returns a new font that contains only the range of characters selected by this function. You can pass -1 for either the lower or upper bound if you want to select all characters from the start or to the end of the font. Example: FONT *myfont; FONT *capitals; FONT *fontcopy; ... /* Create a font of only capital letters */ capitals = extract_font_range(myfont, 'A', 'Z'); /* Create a copy of the font */ fontcopy = extract_font_range(myfont, -1, -1); ... destroy_font(capitals); destroy_font(fontcopy); RETURN VALUE
Returns a pointer to the new font or NULL on error. Remember that you are responsible for destroying the font when you are finished with it to avoid memory leaks. SEE ALSO
get_font_range_begin(3alleg4), get_font_range_end(3alleg4), merge_fonts(3alleg4), transpose_font(3alleg4), exfont(3alleg4) Allegro version 4.4.2 extract_font_range(3alleg4)

Featured Tech Videos

All times are GMT -4. The time now is 07:36 PM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy