![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| create PATH from find command output | rein | UNIX for Dummies Questions & Answers | 3 | 04-01-2008 07:35 AM |
| command to find the path of a file | abhilashnair | UNIX for Dummies Questions & Answers | 3 | 02-17-2008 07:15 PM |
| Setting the current path in the command prompt in (t)csh | reborg | Answers to Frequently Asked Questions | 0 | 10-10-2006 03:02 PM |
| How to prompt for input & accept input in ONE line | newbie168 | Shell Programming and Scripting | 2 | 09-27-2005 05:02 AM |
| find files and using them as input arguements for another command | bobbygrep | UNIX for Dummies Questions & Answers | 1 | 07-18-2001 05:24 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Help-prompt for path and take this as input in find command
HI ,
I am trying to wite a script that will prompt me saying " what is path that you want to find ?". once i specify the path, the script should put this path in the find command mentioned below and execute the script: find <path> -ctime +200 -type f -exec ls -l {} \; for example : Imagine i have script called shell.sh, when i run this it should ask me in the prompt saying "what is path that you want to find ?" when i specify some path like : /usr/local/ then it should take this as input in the find command in the script like below and give me the results: find /usr/local/ -ctime +200 -type f -exec ls -l {} \; Can someone help me out? Thanks, Sandeep |
|
||||
|
Hi ,
i created a sheel script with what you had specified and then ran it as sandeep.sh as below This does not work...it gives me error as follows: [root@bon05 EA]# sandeep.sh -bash: sandeep.sh: command not found ************************************************ ##!/usr/bin/sh -x read dir?"what is the path that you want to find ?" > /EA/sandeep.log find $dir -ctime +200 -type f -exec ls -l {} \; >> /EA/sandeep.log ***************************************************** Please help |
|
||||
|
This is how my program looks can you please tell me why i am getting errors when i run the script as
$./sandeep.sh ./sandeep_new.sh: line 12: read: `dir?what is the path that you want to find ?': not a valid identifier ./sandeep_new.sh: line 13: read: `dir?Please specify a valid path to search ?': not a valid identifier ./sandeep_new.sh: line 23: syntax error near unexpected token `else' ./sandeep_new.sh: line 23: `else' #!/bin/ksh NULL=""; export NULL #If the user specifies NULL value echo "The cvs file script has started............................................" read dir?"what is the path that you want to find ?" read dir?"Please specify a valid path to search ?" if [ "$dir" = "$NULL" ]; then echo "Not a Valid path or path not specified by user,Do you wish to continue:"[Y/N]?"" read ans case "$ans" in y*|Y*) read log?"Please specify a valid log file(ex:/logs/sandeep.log) that needs to created that will dump the results on the log file ?" else n*|N*) echo exiting from program...;; esac if [ "$log" == "$NULL" ]; then echo "Not a Valid path or path not specified by user,Do you wish to continue:"[Y/N]?"" read ans case "$ans" in y*|Y*) read days?"Please specify the valid number as the number of days for the serach ?" if [ "$days" == "$NULL" ]; then echo "Not a Valid path or path not specified by user,Do you wish to continue:"[Y/N]?"" read ans case "$ans" in y*|Y*) find $dir -ctime +$days -type f -exec ls -l {} \; > $log else n*|N*) echo exiting from program...;; esac fi fi fi exit Last edited by bsandeep_80; 01-03-2008 at 07:22 AM.. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|