Directories + shell scripting

This is a discussion on Directories + shell scripting within the Linux Programming forums, part of the Platform Specific Boards category; I would like to search in a directory and sub directories for files so search directoryname cpp txt where i ...

  1. #1
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198

    Directories + shell scripting

    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

  2. #2
    Registered User
    Join Date
    Aug 2001
    Location
    computers/ theatre, travelingstudentL>- Northern California NativeNorthern California3D&Tie-DyeStudent1>. Admirer of C Bangalore Net surfingTeacher >/ >0 nagpurteaching >1  >2
    Posts
    61
    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

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. c shell scripting!!
    By docetes in forum Linux Programming
    Replies: 2
    Last Post: 03-17-2006, 05:02 AM
  2. Shell Scripting...redirecting executable output?
    By Kleid-0 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 05-13-2005, 10:50 AM
  3. What shell is more powerful?
    By xddxogm3 in forum Tech Board
    Replies: 10
    Last Post: 07-24-2004, 10:47 PM
  4. shell scripting ????
    By Unregistered in forum C Programming
    Replies: 0
    Last Post: 02-14-2002, 03:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21