![]() |
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 |
| "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 |
| grep to find content in between curly braces, "{" and "}," | keshav_rk | Shell Programming and Scripting | 4 | 08-09-2007 10:14 PM |
| No utpmx entry: you must exec "login" from lowest level "shell" | peterpan | UNIX for Dummies Questions & Answers | 0 | 01-18-2006 04:15 AM |
| korn shell "loops & arrays" | muzica | Shell Programming and Scripting | 7 | 09-23-2004 03:02 PM |
| Korn shell "select" command | mpegler | Shell Programming and Scripting | 2 | 06-23-2002 09:41 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Find -name "*.txt" in Korn Shell Script
The following find command works on the Korn Shell command line:
find . \( ! -name . -prune \) -type f -name "*.txt" -mtime +100 In the particular directory I'm in, the above find will list correctly the three text files that exist that haven't been modified in over 100 days: ./ep75150aA.txt ./ep13217a_rx_history11122001150339.txt ./ep13217a_rx_history12112001162013.txt ./Report2_ep75150a.txt When that same find command runs within a Korn Shell script (against the same dir), it does not list the three files. It only shows: drwxrwxrwx 2 7 devel 150528 Jul 18 11:28 . What am I missing? Thanks |
|
||||
|
I was thinking I could get away with minimal detail on my first post, but, I was wrong - sorry about that. The script actually accepts parameters that will be used in the find command. I echo the find command to screen, and it 'looks ok" - see snippets below:
#!/bin/ksh PURGEPATH=$1 DAYSOLD=\'$2\' FILESPEC=\'$3\' LOGINDICATOR=$4 ###DAYSOLD=$2 ###FILESPEC=\\$3 tried this ###FILESPEC=\"$3\" and this ...(The script switches to PURGEPATH).... The find looks like this: find . \( ! -name . -prune \) -type f -name $FILESPEC -mtime $DAYSOLD | xargs ls -ldrt >> $LOGFILE I echo the 'variable populated' find command to the screen (and logfile), and it looks like: find . \( ! -name . -prune \) -type f -name '*.txt' -mtime '+100' | xargs ls -ldrt Finally, I put the 'hard-coded' find in the script, with -name '*.txt' (i.e. exactly the second find, above), and it worked! So, even though I echo the 'variable-populated' version to screen, and, it looks just like the 'hard-coded' version, the variable version ($FILESPEC, $DAYSOLD) does not work! I hope I made that clear. My login shell is ksh. The script is ksh. What is it about the use of the variables am I missing? Thanks again! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|