Separating list of input files (*.file) with a comma in bash script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Separating list of input files (*.file) with a comma in bash script
# 1  
Old 05-31-2011
Question Separating list of input files (*.file) with a comma in bash script

Hi all,

I'm trying to get a bash script working for a program (bowtie) which takes a list of input files (*.fastq) and assembles them to an output file (outfile.sam). All the .fastq files are in one folder in my home directory (~/infiles).

The problem is that the 'bowtie' requires that the input files are separated by a comma and with no space in between. E.g.:

infile1.fastq,infile2.fastq,infile3.fastq ...


Does anyone know how I could do this?


#!/bin/bash
fn=*.fastq
./bowtie [parameters] index_file ~/infiles/$fn outfile.sam &

How it should run at the end:

./bowtie [parameters] index_file ~/infiles/infile1.fastq,infile2.fastq,infile3.fastq,infile4.fastq outfile.sam


Your help is greatly appreciated!
Best
# 2  
Old 05-31-2011
Code:
for i in *.fastq; my_variable=`echo $my_variable$i; done

./bowtie [parameters] index_file ~/infiles/$my_varibale outfile.sam

This User Gave Thanks to itkamaraj For This Post:
# 3  
Old 05-31-2011
Many thanks for your reply!

Can it be that a (`) is missing? When I run the command I get an error message (below). Sorry, I'm new to bashSmilie

Code:
#!/bin/bash

for i in *.fastq; my_variable=`echo $my_variable$i; done

./bowtie index_file $my_variable outfile.sam

Error:
./test2.sh: line 3: unexpected EOF while looking for matching ``'
./test2.sh: line 15: syntax error: unexpected end of file


Many thanks again!
# 4  
Old 05-31-2011
Code:
for i in *.fastq; my_variable=`echo $my_variable$i`; done

# 5  
Old 05-31-2011
Thanks! I tried this but I still get an error:

./test2.sh: line 3: syntax error near unexpected token `my_variable=`echo $my_variable$i`'
./test2.sh: line 3: `for i in *.fastq; my_variable=`echo $my_variable$i`; done'
# 6  
Old 05-31-2011
sorry, i forget the do word

for i in *.fastq; do my_variable=`echo $my_variable$i`; done
# 7  
Old 05-31-2011
...worksSmilie Could also have thought of the 'do', sorry.

Many thanks again!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help in input file's in bash script

hello guys i have bash script to open my routers with username and password i made script but i have problem this script can/t read password from file #!/bin/bash router_file="ips" passwd="password.txt" for router in cat ;$router_file do for pass in cat ;$passwd; do res=$(curl -m 1 ... (7 Replies)
Discussion started by: manhoud
7 Replies

2. UNIX for Advanced & Expert Users

Help with ksh script to list, then cp files from a user input date range

Hi, I'm quite new to ksh scripting, can someone help me with this. Requirements: I need to create a script that list the files from a user input date range. e. g. format of file: *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00*... (1 Reply)
Discussion started by: chococrunch6
1 Replies

3. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

4. Shell Programming and Scripting

How to generate a csv files by separating the values from the input file based on position?

Hi All, I need help for doing the following. I have a input file like: aaaaaaaaaabbbbbbbbbbbbbbbbbbbb cccbbbbbaaaaaadddddaaaabbbbbbb now I am trying to generate a output csv file where i will have for e.g. 0-3 chars of each line as the first column in the csv, 4-10 chars of the line as... (3 Replies)
Discussion started by: babom
3 Replies

5. Shell Programming and Scripting

Input file to bash script

Hi, I have this script Script.sh: #!/bin/sh sed 's,\,,g' input.dat > output .dat But i want to run it witb different files. So i want the input file as an input argument to the script, how could i do that. Running it like this: > Script.sh input.dat (2 Replies)
Discussion started by: Johanni
2 Replies

6. UNIX for Dummies Questions & Answers

Bash script to delete file input on command line

1) I wrote a script and gave the desired permissions using "chmod 755 scriptname". Now if i edit the script file, why do i need to set the permission again? Didn't i set the permission attribute.. or if i edit the file, does the inode number of file changes? 2) I am running my unix on a server... (1 Reply)
Discussion started by: animesharma
1 Replies

7. Shell Programming and Scripting

Keeping Null's as it is and separating them by Comma

Hi, I am having source (Oracle) as given below. SourceOBJECT_NAMESUBOBJECT_NAMEOBJECT_IDDATA_OBJECT_IDOBJECT_TYPECREATEDLAST_DDL_TIMESTAMPSTATUSTGSTEST 336559336559TABLE4/15/2009 10:374/15/2009 10:372009-04-15:10:37:57VALIDNNNUNIX 336559336559TABLE4/15/2009 10:374/15/2009... (3 Replies)
Discussion started by: arunvasu2
3 Replies

8. Shell Programming and Scripting

Separating delimited file by pattern with exclusion list

I have a file with the contents below jan_t=jan;feb_t=feb;mar_t=mar;year=2010 jan_t=null;feb_t=feb;mar_t=mar;year=2010 jan_t=jan;feb_t=feb;mar_t=mar;year=2010 I want to extract out all the fields values ending with "_t" , however, i want to exclude feb_t and mar_t from the results In... (6 Replies)
Discussion started by: alienated
6 Replies

9. Shell Programming and Scripting

separating comma delimited words

Hi, I have file with text ________________________________ GROUP:firstname1.lastname1,first_name2.last_name2,first_name3.last_name3 HEAD:firstname.lastname ________________________________ I need help to pick the names separately ie.. Need out put as var1 =firstname1.lastname1... (4 Replies)
Discussion started by: rider29
4 Replies

10. UNIX for Dummies Questions & Answers

Simple script for separating files

Hi all, I was wondering if someone could help me writing a simple script on separating files into separate folders. I have 92 files called various things and I want to separate these folders like so: Create a folder called "1" and put files 1-23 in it Create a folder called "2" and put... (5 Replies)
Discussion started by: hertingm
5 Replies
Login or Register to Ask a Question