![]() |
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 Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to use array values after the loop. | Devesh5683 | Shell Programming and Scripting | 1 | 05-13-2008 07:38 PM |
| printing all array values using dbx 7.2.1 | JamesGoh | High Level Programming | 1 | 12-18-2007 04:07 PM |
| to assign cut values to an array | Syms | UNIX for Dummies Questions & Answers | 6 | 10-29-2007 06:42 AM |
| Assigning values to an array | yongho | UNIX for Dummies Questions & Answers | 4 | 07-13-2005 08:49 PM |
| array values in a command | eeisken | Shell Programming and Scripting | 3 | 06-22-2005 04:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I have a file with 2 lines and 3 filelds
-bash-3.00$ cat del_old_files.cfg $DBA_WORK_DIR *sybdba* 30 $DBA_LOG_DIR *sybdba* 30 I have tried to set up arrays for each field (bash shell) declare -a dirArray=`cut -d' ' -f1 < del_old_files.cfg` declare -a nameArray=`cut -d' ' -f2 < del_old_files.cfg` declare -a daysArray=`cut -d' ' -f3 < del_old_files.cfg` when I query the array I get -bash-3.00$ echo ${dirArray[0]}; echo ${nameArray[0]}; echo ${daysArray[0]} $DBA_WORK_DIR $DBA_LOG_DIR *sybdba* *sybdba* 30 30 -bash-3.00$ echo ${dirArray[1]}; echo ${nameArray[1]}; echo ${daysArray[1]} logically I would expect the [0] and [1] queries to return only 1 value Where did I go wrong? |
|
||||
|
this fails as it is not converting the variables $DBA_WORK_DIR and $DBA_LOG_DIR
-bash-3.00$ while read line ; do set -- $line; find $1 -name \"$2\" -mtime +"$3"; done < del_old_files.cfg find: stat() error $DBA_WORK_DIR: No such file or directory find: stat() error $DBA_LOG_DIR: No such file or directory yet the find statement works outside of the while statement find $DBA_WORK_DIR -name "*sybdba*" -mtime +30 produces the expected list of files |
|
||||
|
Quote:
|
|
||||
|
this fails as it is not converting the variables $DBA_WORK_DIR and $DBA_LOG_DIR
-bash-3.00$ while read line ; do set -- $line; find $1 -name \"$2\" -mtime +"$3"; done < del_old_files.cfg find: stat() error $DBA_WORK_DIR: No such file or directory find: stat() error $DBA_LOG_DIR: No such file or directory yet the find statement works outside of the while statement find $DBA_WORK_DIR -name "*sybdba*" -mtime +30 produces the expected list of files output with set -x -bash-3.00$ ./jjh + read line + set -- '$DBA_WORK_DIR' '*sybdba*' 30 + find '$DBA_WORK_DIR' -name '"*sybdba*"' -mtime +30 find: stat() error $DBA_WORK_DIR: No such file or directory + read line + set -- '$DBA_LOG_DIR' '*sybdba*' 30 + find '$DBA_LOG_DIR' -name '"*sybdba*"' -mtime +30 find: stat() error $DBA_LOG_DIR: No such file or directory + read line -bash-3.00$ so how do I get rid of the single quotes? |
![]() |
| Bookmarks |
| Tags |
| mtime |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|