Directories + shell scripting [Archive] - C Board

PDA

View Full Version : Directories + shell scripting


MethodMan
03-27-2002, 05:17 PM
I would like to search in a directory and sub directories for files

so search directoryname cpp txt
where i can have multiple file types(ex .cpp and .txt)

where ["$1"]
i would like to store the directory as $1, but since I am using shift, it will change it, How can I accomplish this?

Thanks

sigma
03-27-2002, 08:39 PM
I would like to search in a directory and sub directories for files

ls -R | grep fileName

so search directoryname cpp txt
where i can have multiple file types(ex .cpp and .txt)


ls -R cpp txt | grep [cpp, txt]
Note: not sure of syntax of the grep, my references are at work.

where ["$1"]
i would like to store the directory as $1, but since I am using shift, it will change it, How can I accomplish this?


Not clear on what you are trying to do here. I believe that you want to assign the value in $1 to a local variable before the shift

ie: localVariable = $1

starX
03-28-2002, 12:07 AM
If you really want the directory to be stored in $1, all you have to do is pass it in as the first command line parameter. You can change this in the script itself, but I would advise against it, as $1 is a standard name for the first CL param in bash.

I'm not sure of exactly what you're trying to do, but looking up basename will probably help if you actually want to do anything with the files once you know they are there.

starX
www.axisoftime.com