Sponsored Content
Top Forums Shell Programming and Scripting Deleting all lines containing numbers Post 302749141 by dunryc on Thursday 27th of December 2012 03:36:10 PM
Old 12-27-2012
Deleting all lines containing numbers

Hi guys

I have a text file in the following format

Quote:
1410054
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec diam dui,
congue sed tristique eget, pulvinar in enim. Nam tortor odio, rhoncus
sit amet suscipit eget, fringilla non purus. Donec non condimentum neque.
Praesent adipiscing nibh at mauris aliquam non fermentum dolor adipiscing.
Ut dolor mauris, condimentum in dapibus non, convallis vitae quam. Aenean
tincidunt justo at magna congue condimentum. Vestibulum lacus nisl, portt

1410187
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec diam dui,
congue sed tristique eget, pulvinar in enim. Nam tortor odio, rhoncus
sit amet suscipit eget, fringilla non purus. Donec non condimentum neque.
Praesent adipiscing nibh at mauris aliquam non fermentum dolor adipiscing.
Ut dolor mauris, condimentum in dapibus non, convallis vitae quam. Aenean
tincidunt justo at magna congue condimentum. Vestibulum lacus nisl, portt
what i would like ot do is iterate through the file deleting the lines containing only numbers. I have googled this and have been unable to find any help ( maybe its my search terms)

so if any one an give me a heads up i would appreciate it

dunryc
 

10 More Discussions You Might Find Interesting

1. Programming

deleting lines

I am spooling a file from oracle and trying to delete the last line of the spooled file which I am unable to do. Problem is that this file can have multiple records each time and I have no way of knowing how many because the amount can vary. I had an idea of using a while loop to read the... (1 Reply)
Discussion started by: supercbw
1 Replies

2. Shell Programming and Scripting

deleting lines

I am trying deleting lines from a text file using sed.. sed '/OBJECT="ABC/{N;N;N;d; }' will do if i have to delete lines starting with Object and next 3 lines but I was looking for a way to delet lines starting with OBJECT and all the lines till it reaches a blank lines ..or it reaches a... (8 Replies)
Discussion started by: ajnabi
8 Replies

3. Shell Programming and Scripting

Deleting lines above a certain line

Hi, I have a file that gets automatically generated and it would look something like sakjsd adssad {{word}} sddsasd dsdsasa . . . So basically what I want to do is just keep the stuff below the {{word}} marker. The marker includes the brackets. Is there any command to delete the... (3 Replies)
Discussion started by: eltinator
3 Replies

4. Shell Programming and Scripting

Deleting the similar lines

Dear Friends myself Avinash working in bash shell The problem goes like this I have a file called work.txt assume that first colum=mac address second colum= IP third colum = port number ---------------------------------------- 00:12:23:34 192.168.50.1 2 00:12:23:35 192.168.50.1 5... (2 Replies)
Discussion started by: avi.skynet
2 Replies

5. UNIX for Advanced & Expert Users

Deleting lines from a file

How I can delete 100 lines anywhere in a file without opening a file and without renaming the file. (11 Replies)
Discussion started by: Nirgude07
11 Replies

6. Shell Programming and Scripting

Deleting particular lines.

hi all, i have got a scenario in which i need to delete all the lines that ends with file names. e.g. input can be cms/images/services_icons/callback.png cms/cms/images/services_icons/sync.php cms/cms/images/services_icons and output should be cms/cms/images/services_icons ... (13 Replies)
Discussion started by: kashifv
13 Replies

7. Shell Programming and Scripting

deleting lines in ex

Hello, im using ex to manipulate some text. Im trying to delete all the lines except those on which a certain regex can be found. the important part of the script: ex temp << 'HERE' g/regex/p HERE this command prints the lines I want to end up with, but it doesnt delete the others.... (2 Replies)
Discussion started by: drareeg
2 Replies

8. Shell Programming and Scripting

Deleting lines not starting with numbers with sed

Title says all :p Thanks for your help (4 Replies)
Discussion started by: drbiloukos
4 Replies

9. UNIX for Dummies Questions & Answers

Help with deleting lines and saving them

I have a directory question where I ask the user which entry he wants to delete... echo "Which entry?" read entry sed '/^'$entry'/d' file This code does in fact delete that particular entry... HOWEVER, when I go to inquire about that same entry, it still populates like it was never... (4 Replies)
Discussion started by: itech4814
4 Replies

10. Shell Programming and Scripting

Deleting all lines except last 500

Hi All, I want to write a script which first check the line counts of a file if its more than 500 it deletes rest except the last 500.. I tried sed but it looks sed counts line numbers from the head & not from tail.. May be I need a wc -l frist then apply if statement & pass on the line count... (17 Replies)
Discussion started by: ailnilanjan
17 Replies
PDF::Table(3pm) 					User Contributed Perl Documentation					   PDF::Table(3pm)

NAME
PDF::Table - A utility class for building table layouts in a PDF::API2 object. SYNOPSIS
use PDF::API2; use PDF::Table; my $pdftable = new PDF::Table; my $pdf = new PDF::API2(-file => "table_of_lorem.pdf"); my $page = $pdf->page; # some data to layout my $some_data =[ ["1 Lorem ipsum dolor", "Donec odio neque, faucibus vel", "consequat quis, tincidunt vel, felis."], ["Nulla euismod sem eget neque.", "Donec odio neque", "Sed eu velit."], #... and so on ]; $left_edge_of_table = 50; # build the table layout $pdftable->table( # required params $pdf, $page, $some_data, x => $left_edge_of_table, w => 495, start_y => 750, next_y => 700, start_h => 300, next_h => 500, # some optional params padding => 5, padding_right => 10, background_color_odd => "gray", background_color_even => "lightblue", #cell background color for even rows ); # do other stuff with $pdf $pdf->saveas(); ... EXAMPLE
For a complete working example or initial script look into distribution`s 'examples' folder. DESCRIPTION
This class is a utility for use with the PDF::API2 module from CPAN. It can be used to display text data in a table layout within the PDF. The text data must be in a 2d array (such as returned by a DBI statement handle fetchall_arrayref() call). The PDF::Table will automatically add as many new pages as necessary to display all of the data. Various layout properties, such as font, font size, and cell padding and background color can be specified for each column and/or for even/odd rows. Also a (non)repeated header row with different layout properties can be specified. See the METHODS section for complete documentation of every parameter. METHODS
new Returns an instance of the class. There are no parameters. table($pdf, $page_obj, $data, %opts) The main method of this class. Takes a PDF::API2 instance, a page instance, some data to build the table and formatting options. The formatting options should be passed as named parameters. This method will add more pages to the pdf instance as required based on the formatting options and the amount of data. The return value is a 3 item list where The first item is the PDF::API2::Page instance that the table ends on, The second item is the count of pages that the table spans, and The third item is the y position of the table bottom. Example: ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table( $pdf, # A PDF::API2 instance $page_to_start_on, # A PDF::API2::Page instance created with $page_to_start_on = $pdf->page(); $data, # 2D arrayref of text strings x => $left_edge_of_table, #X - coordinate of upper left corner w => 570, # width of table. start_y => $initial_y_position_on_first_page, next_y => $initial_y_position_on_every_new_page, start_h => $table_height_on_first_page, next_h => $table_height_on_every_new_page, #OPTIONAL PARAMS BELOW max_word_length=> 20, # add a space after every 20th symbol in long words like serial numbers padding => 5, # cell padding padding_top => 10, # top cell padding, overides padding padding_right => 10, # right cell padding, overides padding padding_left => 10, # left cell padding, overides padding padding_bottom => 10, # bottom padding, overides -padding border => 1, # border width, default 1, use 0 for no border border_color => 'red',# default black font => $pdf->corefont("Helvetica", -encoding => "utf8"), # default font font_size => 12, font_color_odd => 'purple', font_color_even=> 'black', background_color_odd => 'gray', #cell background color for odd rows background_color_even => 'lightblue', #cell background color for even rows new_page_func => $code_ref, # see section TABLE SPANNING header_props => $hdr_props, # see section HEADER ROW PROPERTIES column_props => $col_props, # see section COLUMN PROPERTIES cell_props => $row_props, # see section CELL PROPERTIES ) HEADER ROW PROPERTIES If the 'header_props' parameter is used, it should be a hashref. It is your choice if it will be anonymous inline hash or predefined one. Also as you can see there is no data variable for the content because the module asumes that the first table row will become the header row. It will copy this row and put it on every new page if 'repeat' param is set. $hdr_props = { # This param could be a pdf core font or user specified TTF. # See PDF::API2 FONT METHODS for more information font => $pdf->corefont("Times", -encoding => "utf8"), font_size => 10, font_color => '#006666', bg_color => 'yellow', repeat => 1, # 1/0 eq On/Off if the header row should be repeated to every new page }; COLUMN PROPERTIES If the 'column_props' parameter is used, it should be an arrayref of hashrefs, with one hashref for each column of the table. The columns are counted from left to right so the hash reference at $col_props[0] will hold properties for the first column from left to right. If you DO NOT want to give properties for a column but to give for another just insert and empty hash reference into the array for the column that you want to skip. This will cause the counting to proceed as expected and the properties to be applyed at the right columns. Each hashref can contain any of the keys shown below: $col_props = [ {},# This is an empty hash so the next one will hold the properties for the second row from left to right. { min_w => 100, # Minimum column width. max_w => 150, # Maximum column width. justify => 'right', # One of left|center|right , font => $pdf->corefont("Times", -encoding => "latin1"), font_size => 10, font_color=> 'blue', background_color => '#FFFF00', }, # etc. ]; If the 'min_w' parameter is used for 'col_props', have in mind that it can be overwritten by the calculated minimum cell witdh if the userdefined value is less that calculated. This is done for safety reasons. In cases of a conflict between column formatting and odd/even row formatting, the former will override the latter. CELL PROPERTIES If the 'cell_props' parameter is used, it should be an arrayref with arrays of hashrefs (of the same dimension as the data array) with one hashref for each cell of the table. Each hashref can contain any of keys shown here: $cell_props = [ [ #This array is for the first row. If header_props is defined it will overwrite this settings. {#Row 1 cell 1 background_color => '#AAAA00', font_color => 'blue', }, # etc. ], [ #Row 2 {#Row 2 cell 1 background_color => '#CCCC00', font_color => 'blue', }, {#Row 2 cell 2 background_color => '#CCCC00', font_color => 'blue', }, # etc. ], # etc. ]; In case of a conflict between column, odd/even and cell formating, cell formating will overwrite the other two. In case of a conflict between header row cell formating, header formating will win. TABLE SPANNING If used the parameter 'new_page_func' must be a function reference which when executed will create a new page and will return the object back to the module. For example you can use it to put Page Title, Page Frame, Page Numbers and other staff that you need. Also if you need some different type of paper size and orientation than the default A4-Portrait for example B2-Landscape you can use this function ref to set it up for you. For more info about creating pages refer to PDF::API2 PAGE METHODS Section. Don't forget that your function must return a page object created with PDF::API2 page() method. text_block( $txtobj, $string, x => $x, y => $y, w => $width, h => $height) Utility method to create a block of text. The block may contain multiple paragraphs. It is mainly used internaly but you can use it from outside for placing formated text anywhere on the sheet. Example: # PDF::API2 objects my $page = $pdf->page; my $txt = $page->text; ($width_of_last_line, $ypos_of_last_line, $left_over_text) = $pdftable->text_block( $txt, $text_to_place, #X,Y - coordinates of upper left corner x => $left_edge_of_block, y => $y_position_of_first_line, w => $width_of_block, h => $height_of_block, #OPTIONAL PARAMS lead => $font_size | $distance_between_lines, align => "left|right|center|justify|fulljustify", hang => $optional_hanging_indent, Only one of the subsequent 3params can be given. They override each other.-parspace is the weightest parspace => $optional_vertical_space_before_first_paragraph, flindent => $optional_indent_of_first_line, fpindent => $optional_indent_of_first_paragraph, indent => $optional_indent_of_text_to_every_non_first_line, ); AUTHOR
Daemmon Hughes DEVELOPMENT
ALL IMPROVEMENTS and BUGS Since Ver: 0.02 Desislav Kamenov VERSION
0.9.5 COPYRIGHT AND LICENSE
Copyright (C) 2006 by Daemmon Hughes, portions Copyright 2004 Stone Environmental Inc. (www.stone-env.com) All Rights Reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available. PLUGS
by Daemmon Hughes Much of the work on this module was sponsered by Stone Environmental Inc. (www.stone-env.com). The text_block() method is a slightly modified copy of the one from Rick Measham's PDF::API2 tutorial at http://pdfapi2.sourceforge.net/cgi-bin/view/Main/YourFirstDocument by Desislav Kamenov The development of this module is sponsored by SEEBURGER AG (www.seeburger.com) Thanks to my friends Krasimir Berov and Alex Kantchev for helpful tips and QA during development. SEE ALSO
PDF::API2 perl v5.12.4 2011-10-20 PDF::Table(3pm)
All times are GMT -4. The time now is 05:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy