Operating System - Linux
1754407 Members
3088 Online
108813 Solutions
New Discussion юеВ

Help required with a script or file filter

 
SOLVED
Go to solution
Nick D'Angelo
Super Advisor

Help required with a script or file filter

All,

I have an output file that I need to re-format. Unfortunately, one of our tools - which can not be re-written or modified, outputs a file in this format.

CACAATGAGAAATACCTGGTGGTGCTCAGCTCA
CTCAGATTGTTCCACATATTCTAGAATAAATAA
ACGAAAGTCTAAAGTACTAAGTTTAGGCAATAC
TCTCTCTCAAGGGCTTCAGCAGGCCCCCAACCT
TACTCAAAGTATAGCAGGATAGTATATTTCAAA
and so on.

However, we want to remove the formatting or the right carriage return at the end of each line so that the output would look like this:

CACAATGAGAAATACCTGGTGGTGCTCAGCTCACTCAGATTGTTCCACATATTCTAGAATAAATAAACGAAAGTCTAAAGTACTAAGTTTAGGCAATACTCTCTCTCAAGGGCTTCAGCAGGCCCCCAACCTTACTCAAAGTATAGCAGGATAGTATATTTCAAA

Any ideas/suggestions?

This is running on Redhat 9.0.
Always learning
4 REPLIES 4
Jeroen Peereboom
Honored Contributor
Solution

Re: Help required with a script or file filter

awk 'printf "%s", $0}' filename > newfile

JP
Stuart Browne
Honored Contributor

Re: Help required with a script or file filter

Or a simpler:

tr -d "\n" < file > newfile

One long-haired git at your service...
Hein van den Heuvel
Honored Contributor

Re: Help required with a script or file filter

And using perl....

perl -pe 'chop' < file > newfile

-p = implicit read loop and print $_ at end
-e = immediate command line
'chop' = the entire program :-). Takes last character from line which is the \n

Hein.
KapilRaj
Honored Contributor

Re: Help required with a script or file filter

cat file |tr "\n" " " # This will leave a space between them if u do not need that

cat file |tr "\n" " " |sed "s/\ //g"

Regds,

Kaps
Nothing is impossible