All pastes #894565 Raw Edit

Mine

public text v1 · immutable
·published 2008-02-07 01:45 UTC
rendered paste body
while(1)
  printf "\n\n"
  cat menu.txt #Loads up the menu
  printf "\n"
  printf "\nENTER YOUR SELECTION>"
  set input = $< #Asks for user selection
  printf "\n"
  if ($input == 'A' || $input == 'a') then #Find file in a directory case
        echo "You have chosen to search for a file."
        printf "Please Enter the File's Directory name or Q to Exit program>"

        set directory  = $<

        #while ($directory != "" && !(-e $directory)) #Keep prompting until the user types a correct folder

        while (1) #Continue looping until the user decides to type something intelligent
            if ($directory != "") then #Make sure no null input is given causing -e to crash
                if (-e $directory) then
                    break; #Continue asking for filename if directory exists
                else if ($directory == 'Q' || $directory == 'q') then #Or give up if they cannot remember and exit
                    echo "Exiting Program...We will miss you! :(..."
                    exit(0)
                endif
            endif
            echo "Directory $directory Does not Exist!"
            printf "Please Enter the File's Directory name or Q to Exit program>"
            set directory  = $<
        end

        printf "\nPlease Enter the File name you wish to search for>"
        set nonomatch #This is a CRITICAL piece which prevents set: no match errors
        set filename=$<

        printf "\n\n------------------------Searching for filename [$filename] in directory [$directory]----------------------------\n\n"

        find $directory -name "$filename" -type f  > tempfile.txt #store filepaths in file
        foreach string (`cat tempfile.txt`) #for each valid file path ls -l it
            ls -l $string
        end
        find $directory -name "$filename" -type d > tempfile2.txt #store dirpaths in file
        foreach string (`cat tempfile2.txt`) #for each valid dir path ls -ld it
            ls -ld $string
        end

        printf "\n\n--------------------Finished Searching for filename [$filename] in directory [$directory]-----------------------\n\n"
        rm -rf tempfile.txt
        rm -rf tempfile2.txt
  else if ($input == 'B' || $input == 'b') then
        echo "You have chosen to calculate a file's length."
  else if ($input == 'C' || $input == 'c') then
        echo "You have chosen to find files of length 0."
  else if ($input == 'D' || $input == 'd') then
        echo "You have chosen to create backup files."
  else if ($input == 'E' || $input == 'e') then
        echo "Exiting Program...We will miss you! :(..."
        exit(0)
  else
    echo "None of these choices match [$input]! Please type letters A through E"
  endif
end