Bash Scripting Help Needed

James McDonald james
Mon Oct 18 05:47:28 PDT 2004


I have a directory on my Linux box named ~/Admin It contains 2 years of 
scripts and hacks that I used to manage the windows (sorry for swearing) 
boxes at my work.

I am trying to grab all the vbs files under the ~/Admin tree and copy 
them to a location so that I can sort and categorize them.

This piece of code gets me a list

find Admin/ -regex .*vbs$

A sample of the output is as follows (note spaces in file names)

Admin/Tools/Scripting/wsh/Shell Extension - Find Path to 
Files/findPathToFiles.vbs
Admin/Tools/Scripting/wsh/Telnet Brisbane/telnet_brisbane.vbs
Admin/Tools/Scripting/wsh/Telnet Brisbane/test.vbs
Admin/Tools/Scripting/wsh/Toggle Proxy/toggle_proxy.vbs
Admin/Tools/Scripting/wsh/UseTraceRT2TestLink/test_link.vbs
Admin/Tools/Scripting/wsh/wallpaper/wallpaper.vbs
Admin/Tools/Scripting/wsh/WindowsScriptingSecretsCode/Components/index/show.vbs

now when I do some thing like

for i in `find Admin/ -regex .*vbs$` ; do echo $i ; done

I get the file name list broken up by the default delimiter of space AND 
newline

Admin/Tools/Scripting/wsh/WMI/Find
Process
In
Server
Farm/find_process_in_server_farm.vbs
Admin/Tools/Scripting/wsh/WMI/List
All
Processes
on
Computer/list_processes.vbs

However I have been trying to do something with the IFS env var

export IFS="" ; for i in `find Admin/ -regex .*vbs$` ; do echo $i ; done
This just makes the whole list of files into one single argument

export IFS="\n" ; for i in `find Admin/ -regex .*vbs$` ; do echo $i ; done
This for some odd reason matches on `n' instead of newline


Can anyone point out to me how I can use some thing such as above to get 
the list of files with spaces in there names and then copy them to 
another location....


Too tired to think....

James






More information about the Linux-users mailing list