GNU bug report logs -
#22001
Is it possible to tab separate concatenated files?
Previous Next
Full log
View this message in rfc822 format
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
This bug report was last modified 6 years and 213 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.