Cat files in subfolders in order given by a listgrep for multiple strings in files, and then list the files in the order of sizeRead all files in folder and subfolders - progress and size/bin/cat: Argument list too longCopy subfolders containing at least n filesHow to batch rename files using loop combination in bash?append files base on a listHow to compress all files from several subfolders?How to compress all files from all subfolders if there is no `Archive.zip` in subfolder?find and sed (find and delete)Bash script to loop through folders and list files to text
English idiomatic equivalents of 能骗就骗 (if you can cheat, then cheat)
Why didn't Caesar move against Sextus Pompey immediately after Munda?
What are the advantages and disadvantages of Manhattan-Style routing?
Is this house-rule removing the increased effect of cantrips at higher character levels balanced?
German idiomatic equivalents of 能骗就骗 (if you can cheat, then cheat)
Would switching to a proportionate House require a constitutional amendment?
Why did the Apple //e make a hideous noise if you inserted the disk upside down?
Is leaving out prefixes like "rauf", "rüber", "rein" when describing movement considered a big mistake in spoken German?
Active wildlife outside the window- Good or Bad for Cat psychology?
Why will we fail creating a self sustaining off world colony?
Russian equivalents of 能骗就骗 (if you can cheat, then cheat)
Early 2000s movie about time travel, protagonist travels back to save girlfriend, then into multiple points in future
Perform mirror symmetry transformation of 3D model (in OBJ)
Cat files in subfolders in order given by a list
Is my guitar action too high or is the bridge too high?
Installed software from source, how to say yum not to install it from package?
Journal standards vs. personal standards
Checkmate in 1 on a Tangled Board
Why should I allow multiple IPs on a website for a single session?
Is it possible to alias a column based on the result of a select+where?
Grid: different background color (of row) based on values
Meaning of the word "good" in context
What is the lowest possible AC?
he and she - er und sie
Cat files in subfolders in order given by a list
grep for multiple strings in files, and then list the files in the order of sizeRead all files in folder and subfolders - progress and size/bin/cat: Argument list too longCopy subfolders containing at least n filesHow to batch rename files using loop combination in bash?append files base on a listHow to compress all files from several subfolders?How to compress all files from all subfolders if there is no `Archive.zip` in subfolder?find and sed (find and delete)Bash script to loop through folders and list files to text
I have a folder x with a number of sufolders ale, bae, galo and inside each subfolder one .pest file.
x/ale/ale.pest
x/bae/bae.pest
x/galo/galo.pest
I have a list in folder y containing the order I should cat .pest files
bae
galo
ale
from my x folder I'm trying
for file in ./*/*.pest; do while read line; do cat "$line".pest; done; done <./y/list
but it's not working.
bash shell-script
add a comment |
I have a folder x with a number of sufolders ale, bae, galo and inside each subfolder one .pest file.
x/ale/ale.pest
x/bae/bae.pest
x/galo/galo.pest
I have a list in folder y containing the order I should cat .pest files
bae
galo
ale
from my x folder I'm trying
for file in ./*/*.pest; do while read line; do cat "$line".pest; done; done <./y/list
but it's not working.
bash shell-script
add a comment |
I have a folder x with a number of sufolders ale, bae, galo and inside each subfolder one .pest file.
x/ale/ale.pest
x/bae/bae.pest
x/galo/galo.pest
I have a list in folder y containing the order I should cat .pest files
bae
galo
ale
from my x folder I'm trying
for file in ./*/*.pest; do while read line; do cat "$line".pest; done; done <./y/list
but it's not working.
bash shell-script
I have a folder x with a number of sufolders ale, bae, galo and inside each subfolder one .pest file.
x/ale/ale.pest
x/bae/bae.pest
x/galo/galo.pest
I have a list in folder y containing the order I should cat .pest files
bae
galo
ale
from my x folder I'm trying
for file in ./*/*.pest; do while read line; do cat "$line".pest; done; done <./y/list
but it's not working.
bash shell-script
bash shell-script
asked 8 hours ago
Madza Yasodara Farias VirgensMadza Yasodara Farias Virgens
304 bronze badges
304 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
To answer the follow-up subtly different question:
I'm still wondering how would be if my subdirectories didnt have same names as in list though....
Let's make some assumptions:
- All the subdirectories of
x
are fair game. - All
.pest
files are fair game. - If you have two
.pest
files with the same name (but in different directories), you don't care what order those two files will becat
ed in.
Then you have:
while read -r name; do
cat x/*/"$name.pest"
done <y/list >concatenated.pest
Adding sanity checking is a little bit trickier but still doable. (I'm not doing that part as I don't know if my assumptions even match your use case.)
Yup. It did it's thing. Thxs!
– Madza Yasodara Farias Virgens
7 hours ago
add a comment |
You have the order in a list, so don't match the filenames with a filename globbing pattern. Instead, construct the names from the strings read from the list:
#!/bin/sh
while read -r name; do
cat "x/$name/$name.pest"
done <y/list >concatenated.pest
This would concatenate all the relevant .pest
files and create a single file called concatenated.pest
from these in the current directory, in the order read from y/list
.
With a bit of checking included:
#!/bin/sh
while read -r name; do
pathname="x/$name/$name.pest"
if [ ! -f "$pathname" ]; then
printf 'Can not find %sn' "$pathname"
echo 'Output file will be incomplete'
exit 1
fi >&2
cat "$pathname"
done <y/list >concatenated.pest
1
Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...
– Madza Yasodara Farias Virgens
7 hours ago
1
@MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual.pest
file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.
– Kusalananda♦
7 hours ago
got it! k I'll post as a different question bc I'm also having to process some files like that. thxs
– Madza Yasodara Farias Virgens
7 hours ago
I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.
– Wildcard
7 hours ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f527571%2fcat-files-in-subfolders-in-order-given-by-a-list%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
To answer the follow-up subtly different question:
I'm still wondering how would be if my subdirectories didnt have same names as in list though....
Let's make some assumptions:
- All the subdirectories of
x
are fair game. - All
.pest
files are fair game. - If you have two
.pest
files with the same name (but in different directories), you don't care what order those two files will becat
ed in.
Then you have:
while read -r name; do
cat x/*/"$name.pest"
done <y/list >concatenated.pest
Adding sanity checking is a little bit trickier but still doable. (I'm not doing that part as I don't know if my assumptions even match your use case.)
Yup. It did it's thing. Thxs!
– Madza Yasodara Farias Virgens
7 hours ago
add a comment |
To answer the follow-up subtly different question:
I'm still wondering how would be if my subdirectories didnt have same names as in list though....
Let's make some assumptions:
- All the subdirectories of
x
are fair game. - All
.pest
files are fair game. - If you have two
.pest
files with the same name (but in different directories), you don't care what order those two files will becat
ed in.
Then you have:
while read -r name; do
cat x/*/"$name.pest"
done <y/list >concatenated.pest
Adding sanity checking is a little bit trickier but still doable. (I'm not doing that part as I don't know if my assumptions even match your use case.)
Yup. It did it's thing. Thxs!
– Madza Yasodara Farias Virgens
7 hours ago
add a comment |
To answer the follow-up subtly different question:
I'm still wondering how would be if my subdirectories didnt have same names as in list though....
Let's make some assumptions:
- All the subdirectories of
x
are fair game. - All
.pest
files are fair game. - If you have two
.pest
files with the same name (but in different directories), you don't care what order those two files will becat
ed in.
Then you have:
while read -r name; do
cat x/*/"$name.pest"
done <y/list >concatenated.pest
Adding sanity checking is a little bit trickier but still doable. (I'm not doing that part as I don't know if my assumptions even match your use case.)
To answer the follow-up subtly different question:
I'm still wondering how would be if my subdirectories didnt have same names as in list though....
Let's make some assumptions:
- All the subdirectories of
x
are fair game. - All
.pest
files are fair game. - If you have two
.pest
files with the same name (but in different directories), you don't care what order those two files will becat
ed in.
Then you have:
while read -r name; do
cat x/*/"$name.pest"
done <y/list >concatenated.pest
Adding sanity checking is a little bit trickier but still doable. (I'm not doing that part as I don't know if my assumptions even match your use case.)
answered 7 hours ago
WildcardWildcard
23.8k10 gold badges68 silver badges179 bronze badges
23.8k10 gold badges68 silver badges179 bronze badges
Yup. It did it's thing. Thxs!
– Madza Yasodara Farias Virgens
7 hours ago
add a comment |
Yup. It did it's thing. Thxs!
– Madza Yasodara Farias Virgens
7 hours ago
Yup. It did it's thing. Thxs!
– Madza Yasodara Farias Virgens
7 hours ago
Yup. It did it's thing. Thxs!
– Madza Yasodara Farias Virgens
7 hours ago
add a comment |
You have the order in a list, so don't match the filenames with a filename globbing pattern. Instead, construct the names from the strings read from the list:
#!/bin/sh
while read -r name; do
cat "x/$name/$name.pest"
done <y/list >concatenated.pest
This would concatenate all the relevant .pest
files and create a single file called concatenated.pest
from these in the current directory, in the order read from y/list
.
With a bit of checking included:
#!/bin/sh
while read -r name; do
pathname="x/$name/$name.pest"
if [ ! -f "$pathname" ]; then
printf 'Can not find %sn' "$pathname"
echo 'Output file will be incomplete'
exit 1
fi >&2
cat "$pathname"
done <y/list >concatenated.pest
1
Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...
– Madza Yasodara Farias Virgens
7 hours ago
1
@MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual.pest
file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.
– Kusalananda♦
7 hours ago
got it! k I'll post as a different question bc I'm also having to process some files like that. thxs
– Madza Yasodara Farias Virgens
7 hours ago
I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.
– Wildcard
7 hours ago
add a comment |
You have the order in a list, so don't match the filenames with a filename globbing pattern. Instead, construct the names from the strings read from the list:
#!/bin/sh
while read -r name; do
cat "x/$name/$name.pest"
done <y/list >concatenated.pest
This would concatenate all the relevant .pest
files and create a single file called concatenated.pest
from these in the current directory, in the order read from y/list
.
With a bit of checking included:
#!/bin/sh
while read -r name; do
pathname="x/$name/$name.pest"
if [ ! -f "$pathname" ]; then
printf 'Can not find %sn' "$pathname"
echo 'Output file will be incomplete'
exit 1
fi >&2
cat "$pathname"
done <y/list >concatenated.pest
1
Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...
– Madza Yasodara Farias Virgens
7 hours ago
1
@MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual.pest
file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.
– Kusalananda♦
7 hours ago
got it! k I'll post as a different question bc I'm also having to process some files like that. thxs
– Madza Yasodara Farias Virgens
7 hours ago
I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.
– Wildcard
7 hours ago
add a comment |
You have the order in a list, so don't match the filenames with a filename globbing pattern. Instead, construct the names from the strings read from the list:
#!/bin/sh
while read -r name; do
cat "x/$name/$name.pest"
done <y/list >concatenated.pest
This would concatenate all the relevant .pest
files and create a single file called concatenated.pest
from these in the current directory, in the order read from y/list
.
With a bit of checking included:
#!/bin/sh
while read -r name; do
pathname="x/$name/$name.pest"
if [ ! -f "$pathname" ]; then
printf 'Can not find %sn' "$pathname"
echo 'Output file will be incomplete'
exit 1
fi >&2
cat "$pathname"
done <y/list >concatenated.pest
You have the order in a list, so don't match the filenames with a filename globbing pattern. Instead, construct the names from the strings read from the list:
#!/bin/sh
while read -r name; do
cat "x/$name/$name.pest"
done <y/list >concatenated.pest
This would concatenate all the relevant .pest
files and create a single file called concatenated.pest
from these in the current directory, in the order read from y/list
.
With a bit of checking included:
#!/bin/sh
while read -r name; do
pathname="x/$name/$name.pest"
if [ ! -f "$pathname" ]; then
printf 'Can not find %sn' "$pathname"
echo 'Output file will be incomplete'
exit 1
fi >&2
cat "$pathname"
done <y/list >concatenated.pest
edited 7 hours ago
answered 8 hours ago
Kusalananda♦Kusalananda
153k18 gold badges302 silver badges483 bronze badges
153k18 gold badges302 silver badges483 bronze badges
1
Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...
– Madza Yasodara Farias Virgens
7 hours ago
1
@MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual.pest
file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.
– Kusalananda♦
7 hours ago
got it! k I'll post as a different question bc I'm also having to process some files like that. thxs
– Madza Yasodara Farias Virgens
7 hours ago
I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.
– Wildcard
7 hours ago
add a comment |
1
Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...
– Madza Yasodara Farias Virgens
7 hours ago
1
@MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual.pest
file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.
– Kusalananda♦
7 hours ago
got it! k I'll post as a different question bc I'm also having to process some files like that. thxs
– Madza Yasodara Farias Virgens
7 hours ago
I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.
– Wildcard
7 hours ago
1
1
Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...
– Madza Yasodara Farias Virgens
7 hours ago
Thank you!!! I'm still wondering how would be if my subdirectories didnt have same names as in list though...
– Madza Yasodara Farias Virgens
7 hours ago
1
1
@MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual
.pest
file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.– Kusalananda♦
7 hours ago
@MadzaYasodaraFariasVirgens In this question, the do all have the same names as the actual
.pest
file. If they don't, then maybe they follow some other pattern that would be easily handled. If not, you may want to ask a separate question about that, but I doubt it would be too difficult.– Kusalananda♦
7 hours ago
got it! k I'll post as a different question bc I'm also having to process some files like that. thxs
– Madza Yasodara Farias Virgens
7 hours ago
got it! k I'll post as a different question bc I'm also having to process some files like that. thxs
– Madza Yasodara Farias Virgens
7 hours ago
I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.
– Wildcard
7 hours ago
I posted a modified version of the answer to illustrate the easiest way to handle differently named subdirectories.
– Wildcard
7 hours ago
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f527571%2fcat-files-in-subfolders-in-order-given-by-a-list%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown