bash question

6 views
Skip to first unread message

OBBARD Darren

unread,
Apr 15, 2019, 6:50:49 AM4/15/19
to ashworth-c...@googlegroups.com
Hi all,

This bash loop works for one user on a machine, but not for another, when pasted into the terminal (note the indenting)

for F in *_1.fastq.gz;
do
stem=$(echo $F | sed 's/_.\+//');
cutadapt -a AGATCGGAAGAGCACACGTCTG -A AGATCGGAAGAGCGTCGTGTAG -o ${stem}_1.trim.fastq -p ${stem}_2.trim.fastq ${stem}_1.fastq.gz ${stem}_2.fastq.gz;
gzip ${stem}_1.trim.fastq &
gzip ${stem}_2.trim.fastq &
done

For both users, echo $SHELL returns "/bin/bash"

The following loop works for both users when pasted into the terminal (note different indenting

for F in *_1.fastq.gz;
do
stem=$(echo $F | sed 's/_.\+//');
cutadapt -a AGATCGGAAGAGCACACGTCTG -A AGATCGGAAGAGCGTCGTGTAG -o ${stem}_1.trim.fastq -p ${stem}_2.trim.fastq ${stem}_1.fastq.gz ${stem}_2.fastq.gz;
gzip ${stem}_1.trim.fastq &
gzip ${stem}_2.trim.fastq &
done

but *both* versions work when placed in a shell script and invoked with

bash ./ThisScript.sh

Why is this?

Thanks,

D.


--
Darren Obbard
darren...@ed.ac.uk

Institute of Evolutionary Biology
University of Edinburgh
Room 2.09, Ashworth 2, Charlotte Auerbach Road
EdinburghEH9 3FL

Office 0131 651 7781
Mobile: 07968 838 635

http://obbard.bio.ed.ac.uk/
-------------------------------------------------------------------

The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.

OBBARD Darren

unread,
Apr 15, 2019, 7:03:33 AM4/15/19
to ashworth-c...@googlegroups.com
Ignore that - I still don't know why it works, but the mail client has stripped all the tabs and half the newlines, making my email unintelligible


--
Darren Obbard
darren...@ed.ac.uk

Institute of Evolutionary Biology
University of Edinburgh
Room 2.09, Ashworth 2, Charlotte Auerbach Road
Edinburgh EH9 3FL

Office 0131 651 7781
Mobile: 07968 838 635

http://obbard.bio.ed.ac.uk/
-------------------------------------------------------------------

> --
> The wiki is at:
> https://www.wiki.ed.ac.uk/display/AshCodes/Ashworth+Codemonkeys
> The mailing list archive is at:
> https://groups.google.com/forum/?fromgroups#!forum/ashworth-code-
> monkeys
> If you have trouble editing the wiki or emailing the group, let me know:
> sujai...@ed.ac.uk
> ---
> You received this message because you are subscribed to the Google Groups
> "Ashworth Codemonkeys" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ashworth-code-mo...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages