bash: reading filenames from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash: reading filenames from file
# 1  
Old 03-04-2008
bash: reading filenames from file

Hi,

I'm trying to write a script that reads filenames from a file and use these filenames in a loop. The filenames are all on one line and the problem is that these filenames have wildcards like * and braces like [0-9] in them.
Right now what I'm doing is something like this:
echo "reading from file" $1
set -x
cat $1 | while read;
do
line=($REPLY)
for file in ${line[@]};
do
command $file;
echo qsub -j oe -o $log tmp.sh; cat tmp.sh;
done
done

If I do it like this $file contains the wildcards and braces but I would like to loop over all file matching the expressions read in from the file.
I've tried doing something like
ls $REPLY
but it seems that $REPLY contains a single-quoted string so that ls doesn't expand the wildcards and complains about not finding the file instead.
Does anyone know how to solve this problem?
Thank you very much!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading from file bash command

Hello, I have a file in the following format id sample platform R1 R2 gene1 gene2 gene3 1 abc llumina R1_001.fastq.gz R2_001.fastq.gz apoe prnpp asp 2 def llumina R1_001.fastq.gz R2_001.fastq.gz apoe prnpp 3 ghi llumina ... (3 Replies)
Discussion started by: nans
3 Replies

2. UNIX for Beginners Questions & Answers

Reading a file from a different directory in a Bash script

Hi all, Given here under a section of a script I am using. SIMDIR="/home/Ins/forces" cd $SIMDIR for file in `ls *.forces` do basename=`echo $file | sed 's/\.*$//'` extname=`echo $file | sed 's/*\(*\)\.\(.*\)/\2\1/'` echo "Processing file: "$basename python convert.py... (4 Replies)
Discussion started by: Theo Score
4 Replies

3. UNIX for Dummies Questions & Answers

Reading filenames with spaces

Hello I've got a certain no. of files in a directory whose names I'm reading and redirecting into a temporary text file using the command below: ls -l | grep ^- | awk '{print $9}'However, whenever the file names contain spaces the above command considers only the part of the file name up to... (5 Replies)
Discussion started by: S. BASU
5 Replies

4. Shell Programming and Scripting

Reading a text file using bash

I've a file in linux with following text: ;ip address hostname put-location alt-put-location tftpserver 192.168.1.1 r01-lab1-net /mnt/nas1/fgbu/ /opt/fgbu/devicebackup 192.168.1.254Now I want to read these values and assign them to particular variables... (6 Replies)
Discussion started by: kashif.live
6 Replies

5. Shell Programming and Scripting

Help in reading a cv file in bash

Hi All, I am trying to read a .csv file which has some 6 columns. Eg: samp.csv one, two, three, four six, seven, eight, nine I used the following code, for line in `cat samp.csv` do echo "$line" done It displays every comma seperated values in each line like, one,... (1 Reply)
Discussion started by: johnwilliams.sp
1 Replies

6. UNIX Desktop Questions & Answers

Appending file extensions to filenames in bash scripts

Hi Suppose I have a variable called filename and it it contains the name of a file. I then would like to append an extension to that filename. The filename currently has no extensions. How do I do this? Thanks (11 Replies)
Discussion started by: ladyAnne
11 Replies

7. Shell Programming and Scripting

Problem in reading file (bash)

i get a name from user first name : last name, in this format. Now i am saving this to a file. what i want is, I do not want to save any name if I already have one entry o that same name..what should i do for example user give robert fernandez this will save in file as robert:fernandez. if... (5 Replies)
Discussion started by: Learnerabc
5 Replies

8. Shell Programming and Scripting

Reading filenames with extension .xml

Hi, I want to write a script to read all the filenames with extension .xml in a directory and pass the name of the file, one by one, to another function. Please help me out. Regards. Saurabh (3 Replies)
Discussion started by: bhalotias
3 Replies

9. UNIX for Dummies Questions & Answers

reading long filenames from nero to AIX

One of my colleagues is having an issue moving files between a windows box and the AIX servers in the office. The filenames are being truncated though i don't know to what extent. He's using Nero to burn the CD and I think he mentioned he's using Joliet. I found another thread that shows a... (1 Reply)
Discussion started by: categoryzd
1 Replies

10. UNIX for Dummies Questions & Answers

reading filenames inside a program

UNIX Sun Ultra60 5.5.1 Hello everybody, I have a problem that seems simple but turns out to be complex (for me at least). My program needs to open a directory (this part is easy), scan each filename and determine whether or not a file with the suffix (.07) exists. So the program would return... (5 Replies)
Discussion started by: j_t_kim
5 Replies
Login or Register to Ask a Question
AMARCHIVER(8)						  System Administration Commands					     AMARCHIVER(8)

NAME
amarchiver - Create, extract or list amanda archive SYNOPSIS
amarchiver --version|--create|--extract|--list [--verbose] [--file file] [filename]... DESCRIPTION
Amarchiver manipulates amanda archive file. On creation, amarchiver doesn't recurse into directories. If a filename specifies a directory, it will be ignored. If it specifies a character device, amarchiver reads the device and archives the data. If a filename specifies a named pipe, amarchiver reads the named pipe and archives the data. Note that this tool is more limited than the Amanda archive library, and may not be appropriate for some archive files -- particularly those which use non-strings in their filenames. OPTIONS
--version print the amarchiver version --create Create an amanda archive. Only the supplied filenames are included. With one --verbose, lists the filenames. With two, lists the filenames and sizes. --list List the filenames in an amanda archive. No additional filenames are allowed on the command line. --extract Extract an amanda archive. If filenames are supplied, only those files are extracted. Files are created in the current directory, suffixed with a dot ('.') and the attribute ID. --verbose Give more information. --file file Create, list or extract from the given file instead of stdin/stdout. SEE ALSO
amanda(8), amanda-archive-format(5) The Amanda Wiki: : http://wiki.zmanda.com/ AUTHORS
Dustin J. Mitchell <dustin@zmanda.com> Zmanda, Inc. (http://www.zmanda.com) Jean-Louis Martineau <martineau@zmanda.com> Zmanda, Inc. (http://www.zmanda.com) Amanda 3.3.1 02/21/2012 AMARCHIVER(8)