how can I provide files as inputs to `tsort`? [on hold]
up vote
-2
down vote
favorite
The input to tsort
can be provided as in this example:
$ tsort <<EOF
a b c
b c d e
EOF
If I have two files as inputs instead,
a
b
c
and
b
c
d
e
how can I provide the two files in bash as inputs to tsort
? Thanks.
coreutils tsort
put on hold as unclear what you're asking by muru, Thomas, mosvy, Isaac, RalfFriedl 2 days ago
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-2
down vote
favorite
The input to tsort
can be provided as in this example:
$ tsort <<EOF
a b c
b c d e
EOF
If I have two files as inputs instead,
a
b
c
and
b
c
d
e
how can I provide the two files in bash as inputs to tsort
? Thanks.
coreutils tsort
put on hold as unclear what you're asking by muru, Thomas, mosvy, Isaac, RalfFriedl 2 days ago
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
The input to tsort
can be provided as in this example:
$ tsort <<EOF
a b c
b c d e
EOF
If I have two files as inputs instead,
a
b
c
and
b
c
d
e
how can I provide the two files in bash as inputs to tsort
? Thanks.
coreutils tsort
The input to tsort
can be provided as in this example:
$ tsort <<EOF
a b c
b c d e
EOF
If I have two files as inputs instead,
a
b
c
and
b
c
d
e
how can I provide the two files in bash as inputs to tsort
? Thanks.
coreutils tsort
coreutils tsort
asked 2 days ago
Tim
1
1
put on hold as unclear what you're asking by muru, Thomas, mosvy, Isaac, RalfFriedl 2 days ago
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as unclear what you're asking by muru, Thomas, mosvy, Isaac, RalfFriedl 2 days ago
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
You need to put all entries of each file into a single line.
You can do so with an unquoted $(...)
which will split on whitespace (and that includes newline) and then you can use echo
on it to print the arguments into a single line.
This should work:
{ echo $(cat file1)
echo $(cat file2)
} | tsort
This should produce the same output as your example does.
UPDATE: The input of tsort is broken on any whitespace, so preserving each file's contents in a single line isn't really important.
In that case, this should be enough:
cat file1 file2 | tsort
Though in your example, you don't really have a number of pairs, there is an odd number of items in your file1. As you noticed already, that is a problem for tsort.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You need to put all entries of each file into a single line.
You can do so with an unquoted $(...)
which will split on whitespace (and that includes newline) and then you can use echo
on it to print the arguments into a single line.
This should work:
{ echo $(cat file1)
echo $(cat file2)
} | tsort
This should produce the same output as your example does.
UPDATE: The input of tsort is broken on any whitespace, so preserving each file's contents in a single line isn't really important.
In that case, this should be enough:
cat file1 file2 | tsort
Though in your example, you don't really have a number of pairs, there is an odd number of items in your file1. As you noticed already, that is a problem for tsort.
add a comment |
up vote
1
down vote
You need to put all entries of each file into a single line.
You can do so with an unquoted $(...)
which will split on whitespace (and that includes newline) and then you can use echo
on it to print the arguments into a single line.
This should work:
{ echo $(cat file1)
echo $(cat file2)
} | tsort
This should produce the same output as your example does.
UPDATE: The input of tsort is broken on any whitespace, so preserving each file's contents in a single line isn't really important.
In that case, this should be enough:
cat file1 file2 | tsort
Though in your example, you don't really have a number of pairs, there is an odd number of items in your file1. As you noticed already, that is a problem for tsort.
add a comment |
up vote
1
down vote
up vote
1
down vote
You need to put all entries of each file into a single line.
You can do so with an unquoted $(...)
which will split on whitespace (and that includes newline) and then you can use echo
on it to print the arguments into a single line.
This should work:
{ echo $(cat file1)
echo $(cat file2)
} | tsort
This should produce the same output as your example does.
UPDATE: The input of tsort is broken on any whitespace, so preserving each file's contents in a single line isn't really important.
In that case, this should be enough:
cat file1 file2 | tsort
Though in your example, you don't really have a number of pairs, there is an odd number of items in your file1. As you noticed already, that is a problem for tsort.
You need to put all entries of each file into a single line.
You can do so with an unquoted $(...)
which will split on whitespace (and that includes newline) and then you can use echo
on it to print the arguments into a single line.
This should work:
{ echo $(cat file1)
echo $(cat file2)
} | tsort
This should produce the same output as your example does.
UPDATE: The input of tsort is broken on any whitespace, so preserving each file's contents in a single line isn't really important.
In that case, this should be enough:
cat file1 file2 | tsort
Though in your example, you don't really have a number of pairs, there is an odd number of items in your file1. As you noticed already, that is a problem for tsort.
edited 2 days ago
answered 2 days ago
Filipe Brandenburger
6,1041625
6,1041625
add a comment |
add a comment |