[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#22001: Is it possible to tab separate concatenated files?
From: |
Bob Proulx |
Subject: |
bug#22001: Is it possible to tab separate concatenated files? |
Date: |
Mon, 23 Nov 2015 16:09:32 -0700 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
Macdonald, Kim - BCCDC wrote:
> Sorry for the confusion - I wanted to add a tab (or even a new line)
> after each file that was concatenated. Actually a new line may be
> better.
>
> For Example:
> Concatenate the files like so:
> >gi|452742846|ref|NZ_CAFD010000001.1| Salmonella enterica subsp., whole
> >genome shotgun sequenceTTTCAGCATATATATAGGCCATCATACATAGCCATATAT
> >gi|452742846|ref|NZ_CAFD010000002.1| Salmonella enterica subsp., whole
> >genome shotgun
> >sequenceCATAGCCATATATACTAGCTGACTGACGTCGCAGCTGGTCAGACTGACGTACGTCGACTGACGTC
> >gi|452742846|ref|NZ_CAFD010000003.1| Salmonella enterica subsp., whole
> >genome shotgun sequenceTATATAGATACATATATCGCGATATCAGACTGCATAGCGTCAG
>
> Right now - Just using cat, they look , like:
> >gi|452742846|ref|NZ_CAFD010000001.1| Salmonella enterica subsp., whole
> >genome shotgun
> >sequenceTTTCAGCATATATATAGGCCATCATACATAGCCATATAT>gi|452742846|ref|NZ_CAFD010000002.1|
> > Salmonella enterica subsp., whole genome shotgun
> >sequenceCATAGCCATATATACTAGCTGACTGACGTCGCAGCTGGTCAGACTGACGTACGTCGACTGACGTC>gi|452742846|ref|NZ_CAFD010000003.1|
> > Salmonella enterica subsp., whole genome shotgun
> >sequenceTATATAGATACATATATCGCGATATCAGACTGCATAGCGTCAG
That example shows a completely different problem. It shows that your
input plain text files have no terminating newline, making them
officially not plain text files but binary files. Because every plain
text line in a file must be terminated with a newline. If they are
not then it isn't a text line. Must be binary.
Why isn't there a newline at the end of the file? Fix that and all of
your problems and many others go away.
Getting ahead of things 1...
If you just can't fix the lack of a newline at the end of those files
then you must handle it explicitly.
for f in *.txt; do
cat "$f"
echo
done
Getting ahead of things 2...
Sometimes people just want a separator between files.
Actually 'tail' will already do this rather well.
tail -n+0 *.txt
==> 1.txt <==
foo
==> 2.txt <==
bar
Bob
- bug#22001: Is it possible to tab separate concatenated files?, Macdonald, Kim - BCCDC, 2015/11/23
- bug#22001: Is it possible to tab separate concatenated files?, Assaf Gordon, 2015/11/23
- bug#22001: Is it possible to tab separate concatenated files?, Assaf Gordon, 2015/11/23
- bug#22001: Is it possible to tab separate concatenated files?, Macdonald, Kim - BCCDC, 2015/11/23
- bug#22001: Is it possible to tab separate concatenated files?, Linda Walsh, 2015/11/26
- bug#22001: Is it possible to tab separate concatenated files?, Eric Blake, 2015/11/26
- bug#22001: Is it possible to tab separate concatenated files?, Erik Auerswald, 2015/11/27