[NTLUG:Discuss] Bash script help

daniel daniel at yacg.com
Tue Sep 6 15:30:23 CDT 2011


I am trying to search through some subtitle files for some key words and 
phrases.  They are ASCII test files.  The filenames have spaces in 
them.  The command I am trying is like this:

for i in *.srt; do echo File: \"$i\" ; cat -n \"$i\" ; done

The "echo" part works fine.  The "cat" part seems to be breaking up the 
filename by spaces and trying to cat files named by the individual parts 
of the filename delimited by spaces.

As you can see, I attemtped to fix the problem by enclosing it in quotes 
but it didn't work.  Running the command manually and enclosing in 
quotes works just fine though.

There is probably a very easy and obvious answer but I'm just not 
getting it.





More information about the Discuss mailing list