[NTLUG:Discuss] Bash script help
Kevin Lee
klee24 at gmail.com
Wed Sep 7 06:12:51 CDT 2011
If you're using bash or ksh you might try changing the IFS variable to be
the newline:
export IFS=$'\n';for i in *.srt;do echo "File: $i";cat -n "$i";done
By default IFS is a space, a tab or a new line. You may want to unset IFS
after your loop, otherwise the rest of the script may behave differently
than expected.
On Tue, Sep 6, 2011 at 15:30, daniel <daniel at yacg.com> wrote:
> 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.
>
>
>
> ______________________________**_________________
> http://www.ntlug.org/mailman/**listinfo/discuss<http://www.ntlug.org/mailman/listinfo/discuss>
>
More information about the Discuss
mailing list