Removing End of Line and carrige return 
Author Message
 Removing End of Line and carrige return

I would like to remove all the end of line and carridge return characters
from all files in one directory. This would hopefully leave me with lots of
1 line files. That could be combined for importing into a database.

Could anyone tell me how to do this in ???

Thanks

Roch



Mon, 16 Apr 2001 03:00:00 GMT  
 Removing End of Line and carrige return
use printf for formatting your output. Since normally you put in a "\n" at
the end of each line of output in your format string, just leave that out
and you'll have one long line of output. I'm not certain how you want the
fields formatted of each line of input, but assuming that you want tabs in
between each field and that you have 3 fields per line of input, you could
have:

awk '{ printf "%s\t%s\t%s\t", $1, $2, $3 }' infile >outfile

Cesar

--
Please remove the UPPERCASE characters from my e-mail address for the real
thing

Quote:

>I would like to remove all the end of line and carridge return characters
>from all files in one directory. This would hopefully leave me with lots of
>1 line files. That could be combined for importing into a database.

>Could anyone tell me how to do this in ???

>Thanks

>Roch




Mon, 16 Apr 2001 03:00:00 GMT  
 Removing End of Line and carrige return


Quote:
>use printf for formatting your output. Since normally you put in a "\n" at
>the end of each line of output in your format string, just leave that out
>and you'll have one long line of output. I'm not certain how you want the
>fields formatted of each line of input, but assuming that you want tabs in
>between each field and that you have 3 fields per line of input, you could
>have:

>awk '{ printf "%s\t%s\t%s\t", $1, $2, $3 }' infile >outfile

or just
awk '{printf "%s", $0} END{printf "\n"}' infile > outfile

That way you dont have to worry about (re-) formatting the line

Mark
--
Mark Katz
ISPC, London - Innovation in data-delivery tools
Tel: (44) 181-455 4665, Fax (44) 181-458 9554
** See our website at http://www.efiche.com **



Mon, 16 Apr 2001 03:00:00 GMT  
 Removing End of Line and carrige return

Quote:

>I would like to remove all the end of line and carridge return characters
>from all files in one directory. This would hopefully leave me with lots of
>1 line files. That could be combined for importing into a database.

>Could anyone tell me how to do this in ???

The Unix tr command will let you do this using the -d option

man tr

BTW, are you sure you want to delete the characters rather than
substitute a space for the carriage return or newline?  Just deleting
the characters will {*filter*}the end of one line up against the start of i
the next.  

tr -d '\012\015' < infile > outfile

will do exactly what you asked, for a file.

You can rewrite this as a simple shell script with a for loop
to cycle through a directory.

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.



Mon, 16 Apr 2001 03:00:00 GMT  
 Removing End of Line and carrige return
awk '{printf $0}' inputfile > outputfile

Quote:

>>I would like to remove all the end of line and carridge return characters
>>from all files in one directory. This would hopefully leave me with lots of
>>1 line files. That could be combined for importing into a database.

>>Could anyone tell me how to do this in ???

--
Greg

http://www.mastnet.net/~jupiter


Mon, 16 Apr 2001 03:00:00 GMT  
 Removing End of Line and carrige return
a have a big problem!!!

I would like to remove the end and carridge return of lines in file wich
containts for exemple this character {4 the records are separated by
RS="$" and each record must be printed in 600 characters long in the output
file

Could anyone tell me how to do this in ???thanks a lot
Nbella

ex:
A{ffgghjjjkkklk}{ffkfkffkfkfk}{4jhjhhj  \n (\012 and \015)
(dhdhdhdhd) \n
{jdsjdjdjdjdj }$M{vgfjflkjflkkflkfkf}{4fkfdkfk \n




Mon, 16 Apr 2001 03:00:00 GMT  
 Removing End of Line and carrige return
do a man on tr. or try something like this
tr -d ["\r\n"] < inputfile > newoutputfile

Dean

Quote:

>I would like to remove all the end of line and carridge return characters
>from all files in one directory. This would hopefully leave me with lots of
>1 line files. That could be combined for importing into a database.

>Could anyone tell me how to do this in ???

>Thanks

>Roch




Mon, 16 Apr 2001 03:00:00 GMT  
 Removing End of Line and carrige return

Quote:

> I would like to remove all the end of line and carridge return characters
> from all files in one directory. This would hopefully leave me with lots of
> 1 line files. That could be combined for importing into a database.

> Could anyone tell me how to do this in ???

> Thanks

> Roch


Remove newlines:
put this in your /bin folder and make it executable
name removeNewlines
================================================
#!/bin/sh
awk 'BEGIN {ORS=""}
/^/' $1
================================================
ls directoryName |
while read filename
do
    removeNewlines $filename >${filename}.noNewLineChar
done
================================================
not tested
 LMS
free sed/awk book:
      ftp://ftp.u-aizu.ac.jp/u-aizu/doc/Tech-Report/1997/97-2-007.ps.gz
      ftp://ftp.u-aizu.ac.jp/u-aizu/doc/Tech-Report/1997/97-2-007.tar.gz


Tue, 17 Apr 2001 03:00:00 GMT  
 Removing End of Line and carrige return

Quote:

> a have a big problem!!!

> I would like to remove the end and carridge return of lines in file wich
> containts for exemple this character {4 the records are separated by
> RS="$" and each record must be printed in 600 characters long in the output
> file

> Could anyone tell me how to do this in ???thanks a lot
> Nbella

> ex:
> A{ffgghjjjkkklk}{ffkfkffkfkfk}{4jhjhhj  \n (\012 and \015)
> (dhdhdhdhd) \n
> {jdsjdjdjdjdj }$M{vgfjflkjflkkflkfkf}{4fkfdkfk \n



BEGIN {
RS="$"}
/{4/ {gsub("\n","");printf "%-600s\n", $0}

I'm not sure if this is what you intended but the output from your
sample file gave two lines each 600 characters long padded with spaces
on the right and starting with:

A{ffgghjjjkkklk}{ffkfkffkfkfk}{4jhjhhj(dhdhdhdhd){jdsjdjdjdjdj }
M{vgfjflkjflkkflkfkf}{4fkfdkfk

Is this what you wanted?

Cesar

--
Please remove the uppercase characters from my e-mail address for the
real thing



Tue, 17 Apr 2001 03:00:00 GMT  
 Removing End of Line and carrige return

% awk '{printf $0}' inputfile > outputfile

Word of caution: this will fail if $0 contains anything that looks like
a printf format string (eg, %s will cause an error because there's no
argument). You should always use
 printf "%s", $0
unless you're sure the input will not contain anything like that.

However tr is a better (as in faster & simpler) solution to this problem
than awk.
--

Patrick TJ McPhee
East York  Canada



Wed, 18 Apr 2001 03:00:00 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. Removing carrige return in a specific position

2. Question: How to remove END OF LINE using AWK or SED

3. Carrige return Problem where did I go wrong

4. How to add a Carrige Return to a memo File

5. remove hard returns at the end of each line in a paragraph?

6. remove blank lines before lines beginning with string

7. blank lines/lines with spaces (how to remove)

8. remove begin and end tags and its content in between

9. removing spaces from front and end of filenames

10. removing the return stack

11. Removing a Record from a Returned SQL Recordset

12. Removing carriage returns

 

 
Powered by phpBB® Forum Software