![]() |
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 |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| "mt erase" command does not work | krishan | Filesystems, Disks and Memory | 2 | 03-19-2009 10:00 PM |
| "find command" to find the files in the current directories but not in the "subdir" | swamymns | Shell Programming and Scripting | 9 | 07-22-2008 11:23 AM |
| passing a list of dynamic names to a "PS" command in shell script? | sachin.tendulka | Shell Programming and Scripting | 3 | 11-21-2007 04:18 AM |
| Passing argument to "at" command | nibl | Shell Programming and Scripting | 2 | 07-22-2006 11:36 PM |
| "man date" command does not work | aptit | UNIX for Dummies Questions & Answers | 1 | 02-15-2002 08:58 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to get Find command work with a variable passing "*" value?
Hi guy,
I have a problem to pass a variable containing '*' value to FIND command. below is the script. It doesn't work by submit below command: rmf.sh name '*.txt' or rmf.sh name *.txt I've tried either optn="-name '$2'" or optn="-name $2"., and there is no luck. Code:
### (script name = rmf.sh)
#!/bin/ksh -x
#$1 - name of option
#$2 - pattern of filename or age of file
if [ "$1" == "name" ]; then
optn="-name '$2'"
else
optn="-mtime +$2"
fi
find . -type f $optn -ls
|
|
|||||
|
Yes you are right "$2" should work also, because I was under the impression that $2 will have the value "*.txt" ie with quotes and it can create problem, therefore I stored the value of $2 in tmp variable after removing any quotes, but in fact tmp is not required here at all, you can remove that.
Quote:
Regards, Tayyab |
|
||||
|
To shereenmotor:
My idea is to create an utility in a shell script for the user removing their old files. The utility leads the user to select an option from the screen manu to remove the file based on the age of file, pattern of file name or both. So the use is able to enter the paramater values. In the script, a string of option for FIND command will be assembled and be passed to the command line. Thanks again. |
![]() |
| Bookmarks |
| Tags |
| mtime |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|