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 CENTOS
text::iconv
Iconv(3) User Contributed Perl Documentation Iconv(3)
NAME
Text::Iconv - Perl interface to iconv() codeset conversion function
SYNOPSIS
use Text::Iconv;
$converter = Text::Iconv->new("fromcode", "tocode");
$converted = $converter->convert("Text to convert");
DESCRIPTION
The Text::Iconv module provides a Perl interface to the iconv() function as defined by the Single UNIX Specification.
The convert() method converts the encoding of characters in the input string from the fromcode codeset to the tocode codeset, and returns
the result.
Settings of fromcode and tocode and their permitted combinations are implementation-dependent. Valid values are specified in the system
documentation; the iconv(1) utility should also provide a -l option that lists all supported codesets.
Utility methods
Text::Iconv objects also provide the following methods:
retval() returns the return value of the underlying iconv() function for the last conversion; according to the Single UNIX Specification,
this value indicates "the number of non-identical conversions performed." Note, however, that iconv implementations vary widely in the
interpretation of this specification.
This method can be called after calling convert(), e.g.:
$result = $converter->convert("lorem ipsum dolor sit amet");
$retval = $converter->retval;
When called before the first call to convert(), or if an error occured during the conversion, retval() returns undef.
get_attr(): This method is only available with GNU libiconv, otherwise it throws an exception. The get_attr() method allows you to query
various attributes which influence the behavior of convert(). The currently supported attributes are trivialp, transliterate, and
discard_ilseq, e.g.:
$state = $converter->get_attr("transliterate");
See iconvctl(3) for details. To ensure portability to other iconv implementations you should first check for the availability of this
method using eval {}, e.g.:
eval { $conv->get_attr("trivialp") };
if ($@)
{
# get_attr() is not available
}
else
{
# get_attr() is available
}
This method should be considered experimental.
set_attr(): This method is only available with GNU libiconv, otherwise it throws an exception. The set_attr() method allows you to set
various attributes which influence the behavior of convert(). The currently supported attributes are transliterate and discard_ilseq,
e.g.:
$state = $converter->set_attr("transliterate");
See iconvctl(3) for details. To ensure portability to other iconv implementations you should first check for the availability of this
method using eval {}, cf. the description of set_attr() above.
This method should be considered experimental.
ERRORS
If the conversion can't be initialized an exception is raised (using croak()).
Handling of conversion errors
Text::Iconv provides a class attribute raise_error and a corresponding class method for setting and getting its value. The handling of
errors during conversion depends on the setting of this attribute. If raise_error is set to a true value, an exception is raised;
otherwise, the convert() method only returns undef. By default raise_error is false. Example usage:
Text::Iconv->raise_error(1); # Conversion errors raise exceptions
Text::Iconv->raise_error(0); # Conversion errors return undef
$a = Text::Iconv->raise_error(); # Get current setting
Per-object handling of conversion errors
As an experimental feature, Text::Iconv also provides an instance attribute raise_error and a corresponding method for setting and getting
its value. If raise_error is undef, the class-wide settings apply. If raise_error is 1 or 0 (true or false), the object settings override
the class-wide settings.
Consult iconv(3) for details on errors that might occur.
Conversion of undef
Converting undef, e.g.,
$converted = $converter->convert(undef);
always returns undef. This is not considered an error.
NOTES
The supported codesets, their names, the supported conversions, and the quality of the conversions are all system-dependent.
AUTHOR
Michael Piotrowski <mxp@dynalabs.de>
SEE ALSO
iconv(1), iconv(3)
perl v5.16.3 2007-10-17 Iconv(3)