Tip to remove line endings and spaces on a pre-formatted text file?
Hi,
At the moment, using Notepad++ to do a search and replace, manually section by section which is real painful. Yeah, so copying each section of the line of text and putting into a file and then search and replace, need at least 3-operations in Notepad++.
Here's hoping I will be able to get some help on how to do this via some script or sed/awk combination maybe?
Basically, I have an Oracle tnsnames,.ora file that contains several section of text like below. So, there will be lots of the following, I just listed two of them at the moment.
I need to convert it to so that it rids itself of the spaces and line endings so that it now looks as below:
i need help..!!!!
i have one big text file estimate data file size 50 - 100GB with 70 Mega Rows.
on OS SUN Solaris version 8
How i can remove first line of the text file.
Please suggest me for solutions.
Thank you very much in advance:) (5 Replies)
Hi,
I wanted to add specific text to each row in a text file containing three rows. Example:
0 8 7 6 5 5
7 8 9 0 7 9
7 8 9 0 1 2
And I want to add a 21 at the beginning of the first row, and blank spaces at the beginning of the second two rows. To get this:
21 0 8 7 6 5 5
7 8... (4 Replies)
Hi all,
I have searched and found various threads about removing spaces from a field within a text file. Unfortunately, I have not found exactly what I'm looking for, nor am I adept enough to modify what I've found into what I need.
I use the following command to remove the first line... (3 Replies)
Hi,
I have this problem that there are blank spaces in my text file... i want to remove them
line 1
line 2
line 3
I want to remove the space between line 2 and line 3... I tried sed... it work but it prints the whole text file at the command prompt which i dont want....
sde i tried was... (4 Replies)
I have been trying to remove some improperly formatted lines of output from fortran code I have been using. The problem is that I have some singularities in the math for some points that causes an incorrectly large value to be reported that exceeds the normal formating set in the code resulting in... (2 Replies)
what is the sed command to remove the first two characters of every line of a text file?
each line of the text file has the same amount of characters, and they are ALL NUMERIC. there are hundreds of lines though.
for example,
>cat file1.txt
10081551
10081599
10082234
10082259
20081134... (20 Replies)
Hi All,
I am creating a text file using perl. The first record I am writing as "$line" and all the other as "\n$line". At the end the file is having N number of lines. I am using this file for MLOAD (Teradata), which is reading N+1 lines in the file and failing.I am not able to find new line... (2 Replies)
I have a text file with a line of text that contains numbers and text formatted into groups. I need to extract the number that can be either 1,2 or 3 digits long. Then write it to a variable, but i need to remove any leading spaces in the number first.
I can get the numbers out but how to remove... (12 Replies)
I have a file of about 10k records and eace line is having an extra space of 5 byte at the end.. Iwant to remove the extra spaces at the end of each line.. Can someone please help me out.. I tried using sed command and its not working... can someone please help me out. (3 Replies)
Hi, suppose I have the following data:
albert music=top40 age=20
bob music=punk rock age=25
candy music=r n b age=22
dave music=mozart or bach only age=30
I want to extract and manipulate the music column but it's got spaces in it. How can I substitute the space with an underscore... (2 Replies)
Discussion started by: almonds
2 Replies
LEARN ABOUT CENTOS
test::eol
Test::EOL(3) User Contributed Perl Documentation Test::EOL(3)NAME
Test::EOL - Check the correct line endings in your project
SYNOPSIS
"Test::EOL" lets you check for the presence of trailing whitespace and/or windows line endings in your perl code. It reports its results in
standard "Test::Simple" fashion:
use Test::EOL tests => 1;
eol_unix_ok( 'lib/Module.pm', 'Module is ^M free');
and to add checks for trailing whitespace:
use Test::EOL tests => 1;
eol_unix_ok( 'lib/Module.pm', 'Module is ^M and trailing whitespace free', { trailing_whitespace => 1 });
Module authors can include the following in a t/eol.t and have "Test::EOL" automatically find and check all perl files in a module
distribution:
use Test::EOL;
all_perl_files_ok();
or
use Test::EOL;
all_perl_files_ok( @mydirs );
and if authors would like to check for trailing whitespace:
use Test::EOL;
all_perl_files_ok({ trailing_whitespace => 1 });
or
use Test::EOL;
all_perl_files_ok({ trailing_whitespace => 1 }, @mydirs );
DESCRIPTION
This module scans your project/distribution for any perl files (scripts, modules, etc) for the presence of windows line endings.
FUNCTIONS
all_perl_files_ok
all_perl_files_ok( [ \%options ], [ @directories ] )
Applies "eol_unix_ok()" to all perl files found in @directories (and sub directories). If no <@directories> is given, the starting point is
one level above the current running script, that should cover all the files of a typical CPAN distribution. A perl file is *.pl or *.pm or
*.t or a file starting with "#!...perl"
Valid "\%options" currently are:
o trailing_whitespace
By default Test::EOL only looks for Windows (CR/LF) line-endings. Set this to true to raise errors if any kind of trailing whitespace
is present in the file.
o all_reasons
Normally Test::EOL reports only the first error in every file (given that a text file originated on Windows will fail every single
line). Set this a true value to register a test failure for every line with an error.
If the test plan is defined:
use Test::EOL tests => 3;
all_perl_files_ok();
the total number of files tested must be specified.
eol_unix_ok
eol_unix_ok ( $file [, $text] [, \%options ] )
Run a unix EOL check on $file. For a module, the path (lib/My/Module.pm) or the name (My::Module) can be both used. $text is the diagnostic
label emited after the "ok"/"not ok" TAP output. "\%options" takes the same values as described in "all_perl_files_ok".
EXPORT
A list of functions that can be exported. You can delete this section if you don't export anything, such as for a purely object-oriented
module.
ACKNOWLEDGEMENTS
Shamelessly ripped off from Test::NoTabs.
SEE ALSO
Test::More, Test::Pod. Test::Distribution, <Test:NoWarnings>, Test::NoTabs, Module::Install::AuthorTests.
AUTHORS
o Arthur Axel 'fREW' Schmidt <frioux@gmail.com>
o Florian Ragwitz <rafl@debian.org>
o Kent Fredric <kentfredric@gmail.com>
o Peter Rabbitson <ribasushi@cpan.org>
o Tomas Doran <bobtfish@bobtfish.net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Tomas Doran.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
perl v5.16.3 2012-06-15 Test::EOL(3)