[NTLUG:Discuss] Bash script help

Wayne Walker wwalker at solid-constructs.com
Wed Sep 7 10:11:35 CDT 2011


On Wed, Sep 07, 2011 at 06:12:51AM -0500, Kevin Lee wrote:
> 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.

Cool.

(IFS=$'\n';for i in *.srt;do echo "File: $i";cat -n "$i";done)

the parens will run it in a sub shell so the parent (your interactive
shell) won't be affected by the IFS change.

-- 

Wayne Walker
wwalker at solid-constructs.com
(512) 633-8076
Senior Consultant
Solid Constructs, LLC



More information about the Discuss mailing list