SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with While []... done in bash musta1234 Bioinformatics 7 04-08-2014 05:08 PM
bash help Liy Bioinformatics 5 01-28-2014 06:22 AM
Float Arithmatic in Bash vishal.rossi Bioinformatics 3 05-06-2013 01:34 AM
New to BAsh. Encountered an error vishal.rossi Bioinformatics 4 04-26-2013 07:34 PM
Running stampy in bash script grafab Bioinformatics 7 04-23-2012 02:00 AM

Reply
 
Thread Tools
Old 09-01-2016, 08:36 AM   #1
JQL
Member
 
Location: MO, USA

Join Date: Apr 2011
Posts: 83
Default bash shell question

I tried to do a simple task in batch--unzipping many gz files. I have many .gz files, but how come it only unzipped one file then finished? Anything wrong with my script? thanks. John


## unzip fastq.gz
for i in *.fastq.gz
do
#echo $i
zcat "$i" > "${i%.*}"
done
JQL is offline   Reply With Quote
Old 09-01-2016, 08:59 AM   #2
azneto
Member
 
Location: Brazil

Join Date: Dec 2009
Posts: 24
Default

have you tried 'gunzip *.fastq.gz' ?
azneto is offline   Reply With Quote
Old 09-01-2016, 09:32 AM   #3
JQL
Member
 
Location: MO, USA

Join Date: Apr 2011
Posts: 83
Default

gunzip *.fastq.gz will delete original gz files. i want to keep original files.



Quote:
Originally Posted by azneto View Post
have you tried 'gunzip *.fastq.gz' ?
JQL is offline   Reply With Quote
Old 09-01-2016, 09:39 AM   #4
azneto
Member
 
Location: Brazil

Join Date: Dec 2009
Posts: 24
Default

for i in `ls *.fastq.gz`; do gunzip -c $i > $i.fastq; done
azneto is offline   Reply With Quote
Old 09-01-2016, 09:47 AM   #5
JQL
Member
 
Location: MO, USA

Join Date: Apr 2011
Posts: 83
Default

I tried
for i in `ls *.fastq.gz`; do gunzip -c $i > ${i%.gz}; done

still only unzipped just first file then finished. no error. very strange.


Quote:
Originally Posted by azneto View Post
for i in `ls *.fastq.gz`; do gunzip -c $i > $i.fastq; done
JQL is offline   Reply With Quote
Old 09-01-2016, 10:02 AM   #6
azneto
Member
 
Location: Brazil

Join Date: Dec 2009
Posts: 24
Default

I tested your version of the command and it worked fine. It could be something related to permissions.
azneto is offline   Reply With Quote
Old 09-01-2016, 10:04 AM   #7
JQL
Member
 
Location: MO, USA

Join Date: Apr 2011
Posts: 83
Default

thanks. I thought it might be related to something internal. will find out.

Quote:
Originally Posted by azneto View Post
I tested your version of the command and it worked fine. It could be something related to permissions.
JQL is offline   Reply With Quote
Old 09-01-2016, 11:29 AM   #8
Richard Finney
Senior Member
 
Location: bethesda

Join Date: Feb 2009
Posts: 700
Default

for i in $(ls *.gz); do sn=`echo $i | sed 's/\.gz$//'`; zcat $i > $sn; done;
Richard Finney is offline   Reply With Quote
Old 09-01-2016, 02:39 PM   #9
JQL
Member
 
Location: MO, USA

Join Date: Apr 2011
Posts: 83
Default

another nice way to do it.

I really think something is going on with my server. It still finished after doing one file. I will ask my admin tomorrow. Will let you know.

By any chance did this happen to any one of you here?

Quote:
Originally Posted by Richard Finney View Post
for i in $(ls *.gz); do sn=`echo $i | sed 's/\.gz$//'`; zcat $i > $sn; done;
JQL is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 07:58 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO