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
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
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
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
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
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
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
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
Title says all :p
Thanks for your help (4 Replies)
Discussion started by: drbiloukos
4 Replies
9. UNIX for Dummies Questions & Answers
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
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
LEARN ABOUT DEBIAN
cgi::application::plugin::json
CGI::Application::Plugin::JSON(3pm) User Contributed Perl Documentation CGI::Application::Plugin::JSON(3pm)
NAME
CGI::Application::Plugin::JSON - easy manipulation of JSON headers
SYNOPSIS
use CGI::Application::Plugin::JSON ':all';
# add_json_header() is cumulative
$self->add_json_header( foo => 'Lorem ipsum...');
$self->add_json_header( bar => [ 0, 2, 3, 4 ] );
$self->add_json_header( baz => { stuff => 1, more_stuff => 2 } );
# json_header() is not cumulative
$self->json_header( foo => 'Lorem ipsum...');
# in case we're printing our own headers
print "X-JSON: " . $self->json_header_string();
# clear out everything in the outgoing JSON headers
$self->clear_json_header();
# or send the JSON in the document body
$self->json_body( { foo => 'Lorem ipsum', bar => [ 0, 2, 3 ] } );
# send the JSON back in the document body, but execute it using a Javascript callback
$self->json_callback('alert', { foo => 'Lorem ipsum', bar => [ 0, 2, 3 ] } );
DESCRIPTION
When communicating with client-side JavaScript, it is common to send data in "X-JSON" HTTP headers or through the document body as content-
type "application/json".
This plugin adds a couple of convenience methods to make that just a little bit easier.
HEADER METHODS
json_header
This method takes name-value pairs and sets them to be used in the outgoing JSON. It is not cummulative and works similarly to
"header_props". Use it only if you have all of the values up front. In most cases add_json_header is probably what you want.
# only the 2nd call will actually set data that will be sent
$self->json_header( foo => 'Lorem ipsum...');
$self->json_header( bar => [ 0, 2, 3, 4 ] );
add_json_header
This method takes name-value pairs and sets them to be used in the outgoing JSON. It is cummulative and works similarly to "header_add";
meaning multiple calls will add to the hash of outgoing values.
# both 'foo' and 'bar' will exist in the hash sent out
$self->json_header( foo => 'Lorem ipsum...');
$self->json_header( bar => [ 0, 2, 3, 4 ] );
clear_json_header
This method will remove anything that was previously set by both json_header and add_json_header. This means that no "X-JSON" header will
be sent.
json_header_string
This method will create the actual HTTP header string that will be sent to the browser. This plugin uses it internally to send the header,
but it might be useful to use directly if you are printing your own HTTP headers (using a "header_type" of "none").
$self->header_type('none');
print $self->json_header_string();
json_header_value
This method will return the values being sent in the JSON header. If you pass in the key of the value you want, you will get just that
value. Else all name-value pairs will be returned.
my $value = $self->json_header_value('foo');
my %values = $self->json_header_value();
BODY METHODS
json_body
This method will take the given Perl structure, turn it into JSON, set the appropriate content-type, and then return the JSON.
return $self->json_body({ foo => 'stuff', bar => [0,1,2,3]} );
json_callback
This method will take the given Perl structure, turn it into JSON, set the appropriate content-type, and then return a Javascript snippet
where the given callback is called with the resulting JSON.
return $self->json_callback('alert', { foo => 'stuff', bar => [0,1,2,3]} );
# would result in something like the following being sent to the client
alert({ foo => 'stuff', bar => [0,1,2,3]});
MISC METHODS
to_json
This method is just a convenient wrapper around JSON::Any's "encode".
from_json
This method is just a convenient wrapper around JSON::Any's "decode".
AUTHOR
Michael Peters, "<mpeters@plusthree.com>"
BUGS
Please report any bugs or feature requests to "bug-cgi-application-plugin-viewsource@rt.cpan.org", or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI-Application-Plugin-JSON <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI-Application-
Plugin-JSON>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
COPYRIGHT & LICENSE
Copyright 2006 Michael Peters, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.12.4 2011-11-11 CGI::Application::Plugin::JSON(3pm)