bash script split file names
I have the following bash script:
#!/bin/bash
for r in $(find . -name "*.fastq");
do
cat <<EOF
#qsub <<EOF
#!/bin/bash -l
#PBS -N $r
EOF
done
Unfortunately, all filename get split:
> sh cFiltering_pbs.sh
#qsub <<EOF
#!/bin/bash -l
#PBS -N ./76A
#qsub <<EOF
#!/bin/bash -l
#PBS -N Paired.fastq
#qsub <<EOF
#!/bin/bash -l
#PBS -N ./104A
#qsub <<EOF
#!/bin/bash -l
#PBS -N Paired.fastq
Here is the find output:
find . -name "*.fastq"
./76A Paired.fastq
./104A Paired.fastq
What did I miss?
bash
add a comment |
I have the following bash script:
#!/bin/bash
for r in $(find . -name "*.fastq");
do
cat <<EOF
#qsub <<EOF
#!/bin/bash -l
#PBS -N $r
EOF
done
Unfortunately, all filename get split:
> sh cFiltering_pbs.sh
#qsub <<EOF
#!/bin/bash -l
#PBS -N ./76A
#qsub <<EOF
#!/bin/bash -l
#PBS -N Paired.fastq
#qsub <<EOF
#!/bin/bash -l
#PBS -N ./104A
#qsub <<EOF
#!/bin/bash -l
#PBS -N Paired.fastq
Here is the find output:
find . -name "*.fastq"
./76A Paired.fastq
./104A Paired.fastq
What did I miss?
bash
5
for r in $(find . -name "*.fastq");is pretty bad...
– don_crissti
3 hours ago
1
Are all yourfastqfiles in the same directory?
– roaima
3 hours ago
yes, they're all in the same directory. I solved it with this unix.stackexchange.com/a/9499/34872
– user977828
2 hours ago
That's a poor solution for your situation
– roaima
2 hours ago
2
see: Why does my shell script choke on whitespace or other special characters? and Recursively iterate through files in a directory and also mywiki.wooledge.org/WordSplitting
– ilkkachu
2 hours ago
add a comment |
I have the following bash script:
#!/bin/bash
for r in $(find . -name "*.fastq");
do
cat <<EOF
#qsub <<EOF
#!/bin/bash -l
#PBS -N $r
EOF
done
Unfortunately, all filename get split:
> sh cFiltering_pbs.sh
#qsub <<EOF
#!/bin/bash -l
#PBS -N ./76A
#qsub <<EOF
#!/bin/bash -l
#PBS -N Paired.fastq
#qsub <<EOF
#!/bin/bash -l
#PBS -N ./104A
#qsub <<EOF
#!/bin/bash -l
#PBS -N Paired.fastq
Here is the find output:
find . -name "*.fastq"
./76A Paired.fastq
./104A Paired.fastq
What did I miss?
bash
I have the following bash script:
#!/bin/bash
for r in $(find . -name "*.fastq");
do
cat <<EOF
#qsub <<EOF
#!/bin/bash -l
#PBS -N $r
EOF
done
Unfortunately, all filename get split:
> sh cFiltering_pbs.sh
#qsub <<EOF
#!/bin/bash -l
#PBS -N ./76A
#qsub <<EOF
#!/bin/bash -l
#PBS -N Paired.fastq
#qsub <<EOF
#!/bin/bash -l
#PBS -N ./104A
#qsub <<EOF
#!/bin/bash -l
#PBS -N Paired.fastq
Here is the find output:
find . -name "*.fastq"
./76A Paired.fastq
./104A Paired.fastq
What did I miss?
bash
bash
asked 3 hours ago
user977828user977828
3471516
3471516
5
for r in $(find . -name "*.fastq");is pretty bad...
– don_crissti
3 hours ago
1
Are all yourfastqfiles in the same directory?
– roaima
3 hours ago
yes, they're all in the same directory. I solved it with this unix.stackexchange.com/a/9499/34872
– user977828
2 hours ago
That's a poor solution for your situation
– roaima
2 hours ago
2
see: Why does my shell script choke on whitespace or other special characters? and Recursively iterate through files in a directory and also mywiki.wooledge.org/WordSplitting
– ilkkachu
2 hours ago
add a comment |
5
for r in $(find . -name "*.fastq");is pretty bad...
– don_crissti
3 hours ago
1
Are all yourfastqfiles in the same directory?
– roaima
3 hours ago
yes, they're all in the same directory. I solved it with this unix.stackexchange.com/a/9499/34872
– user977828
2 hours ago
That's a poor solution for your situation
– roaima
2 hours ago
2
see: Why does my shell script choke on whitespace or other special characters? and Recursively iterate through files in a directory and also mywiki.wooledge.org/WordSplitting
– ilkkachu
2 hours ago
5
5
for r in $(find . -name "*.fastq"); is pretty bad...– don_crissti
3 hours ago
for r in $(find . -name "*.fastq"); is pretty bad...– don_crissti
3 hours ago
1
1
Are all your
fastq files in the same directory?– roaima
3 hours ago
Are all your
fastq files in the same directory?– roaima
3 hours ago
yes, they're all in the same directory. I solved it with this unix.stackexchange.com/a/9499/34872
– user977828
2 hours ago
yes, they're all in the same directory. I solved it with this unix.stackexchange.com/a/9499/34872
– user977828
2 hours ago
That's a poor solution for your situation
– roaima
2 hours ago
That's a poor solution for your situation
– roaima
2 hours ago
2
2
see: Why does my shell script choke on whitespace or other special characters? and Recursively iterate through files in a directory and also mywiki.wooledge.org/WordSplitting
– ilkkachu
2 hours ago
see: Why does my shell script choke on whitespace or other special characters? and Recursively iterate through files in a directory and also mywiki.wooledge.org/WordSplitting
– ilkkachu
2 hours ago
add a comment |
1 Answer
1
active
oldest
votes
Instead of using find you can simply loop through the files themselves. Notice that I have double-quoted "$r"; you need to do that to keep the space in the filenames intact and unparsed by the shell.
for r in *.fastq
do
# Stuff using "$r"...
:
done
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%2f495186%2fbash-script-split-file-names%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Instead of using find you can simply loop through the files themselves. Notice that I have double-quoted "$r"; you need to do that to keep the space in the filenames intact and unparsed by the shell.
for r in *.fastq
do
# Stuff using "$r"...
:
done
add a comment |
Instead of using find you can simply loop through the files themselves. Notice that I have double-quoted "$r"; you need to do that to keep the space in the filenames intact and unparsed by the shell.
for r in *.fastq
do
# Stuff using "$r"...
:
done
add a comment |
Instead of using find you can simply loop through the files themselves. Notice that I have double-quoted "$r"; you need to do that to keep the space in the filenames intact and unparsed by the shell.
for r in *.fastq
do
# Stuff using "$r"...
:
done
Instead of using find you can simply loop through the files themselves. Notice that I have double-quoted "$r"; you need to do that to keep the space in the filenames intact and unparsed by the shell.
for r in *.fastq
do
# Stuff using "$r"...
:
done
answered 2 hours ago
roaimaroaima
43.4k553116
43.4k553116
add a comment |
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%2f495186%2fbash-script-split-file-names%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
5
for r in $(find . -name "*.fastq");is pretty bad...– don_crissti
3 hours ago
1
Are all your
fastqfiles in the same directory?– roaima
3 hours ago
yes, they're all in the same directory. I solved it with this unix.stackexchange.com/a/9499/34872
– user977828
2 hours ago
That's a poor solution for your situation
– roaima
2 hours ago
2
see: Why does my shell script choke on whitespace or other special characters? and Recursively iterate through files in a directory and also mywiki.wooledge.org/WordSplitting
– ilkkachu
2 hours ago