HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- find command with variables and *
Operating System - HP-UX
1833365
Members
3393
Online
110052
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2009 07:49 AM
11-05-2009 07:49 AM
find command with variables and *
I am trying to write a script for a backup.
I have parsed yesterdays date in a variable, taken for the oracle database.
I then want to do a find in a directory with that date (all my backup file name start with a date)
20091028_online_bu_copy_TS_USERS-ioksum8q
20091028_online_bu_copy_TS_SYSTEM-ipksumm4
20091028_online_bu_copy_TS_UNDOTBS1-iqksumn7
20091028_online_bu_copy_TS_SYSAUX-irksumo0
20091028_cf&spfile_NASMB_c-2956975978-20091028-03
20091029_online_bu_copy_TS_USERS-o7kt13mq
20091029_online_bu_copy_TS_SYSTEM-o8kt144o
----------------------
YESTERDAY=`sqlplus -silent " / as sysdba" << EOF
set pagesize 0 feedback off heading off verify off echo off
Select to_char(sysdate-1,'YYYYMMDD') from dual
Exit;
EOF`
# echo $YESTERDAY
# 20091028
So I am having problems trying to do a find of files in a directory with $YESTERDAY in the file name.
find . -type f -name '*$YESTERDAY_*'
- DOES NOT WORK.
I have parsed yesterdays date in a variable, taken for the oracle database.
I then want to do a find in a directory with that date (all my backup file name start with a date)
20091028_online_bu_copy_TS_USERS-ioksum8q
20091028_online_bu_copy_TS_SYSTEM-ipksumm4
20091028_online_bu_copy_TS_UNDOTBS1-iqksumn7
20091028_online_bu_copy_TS_SYSAUX-irksumo0
20091028_cf&spfile_NASMB_c-2956975978-20091028-03
20091029_online_bu_copy_TS_USERS-o7kt13mq
20091029_online_bu_copy_TS_SYSTEM-o8kt144o
----------------------
YESTERDAY=`sqlplus -silent " / as sysdba" << EOF
set pagesize 0 feedback off heading off verify off echo off
Select to_char(sysdate-1,'YYYYMMDD') from dual
Exit;
EOF`
# echo $YESTERDAY
# 20091028
So I am having problems trying to do a find of files in a directory with $YESTERDAY in the file name.
find . -type f -name '*$YESTERDAY_*'
- DOES NOT WORK.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2009 07:55 AM
11-05-2009 07:55 AM
Re: find command with variables and *
Use " (double quotes) rather than ' (single quote).
find . -type f -name "*$YESTERDAY_*"
should work fine.
find . -type f -name "*$YESTERDAY_*"
should work fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2009 07:57 AM
11-05-2009 07:57 AM
Re: find command with variables and *
Nope it returns all.
oracle@mbowodb1 NASMB> find . -type f -name "*$YESTERDAY_*"
./20091030_cf&spfile_NASMB_c-2956975978-20091030-02
./20091030_cf&spfile_NASMB_c-2956975978-20091030-00
./20091030_online_bu_copy_TS_UNDOTBS1-68kt3ngs
./20091030_online_bu_copy_TS_SYSAUX-69kt3nhl
./20091028_cf&spfile_NASMB_c-2956975978-20091028-03
./20091028_online_bu_copy_TS_SYSTEM-ipksumm4
./20091028_online_bu_copy_TS_UNDOTBS1-iqksumn7
./20091028_online_bu_copy_TS_SYSAUX-irksumo0
./20091030_online_bu_copy_TS_USERS-66kt3n25
./20091030_online_bu_copy_TS_SYSTEM-67kt3nfo
./20091029_cf_copy-v0kt1531.ctl
./20091029_cf&spfile_NASMB_c-2956975978-20091029-00
./20091029_online_bu_copy_TS_UNDOTBS1-o9kt1465
./20091029_online_bu_copy_TS_SYSAUX-oakt146u
./20091103_cf&spfile-AUTO_c-2956975978-20091103-01
./20091105_cf&spfile-AUTO_c-2956975978-20091105-00
./20091104_online_bu_copy_TS_SYSAUX-98kthi8g
./20091104_cf&spfile-AUTO_c-2956975978-20091104-02
./20091028_online_bu_copy_TS_USERS-ioksum8q
./20091104_online_bu_copy_TS_UNDOTBS1-97kthi7m
./20091029_online_bu_copy_TS_USERS-o7kt13mq
./20091029_online_bu_copy_TS_SYSTEM-o8kt144o
./20091103_cf_copy-pbktem96.ctl
./20091104_online_bu_copy_TS_SYSTEM-96kthi6j
./20091103_cf&spfile-AUTO_c-2956975978-20091103-00
./20091104_online_bu_copy_TS_USERS-95kthhov
./20091103_online_bu_copy_TS_SYSAUX-dkkted6f
./20091103_cf_copy-p9kteeo8.ctl
oracle@mbowodb1 NASMB> find . -type f -name "*$YESTERDAY_*"
./20091030_cf&spfile_NASMB_c-2956975978-20091030-02
./20091030_cf&spfile_NASMB_c-2956975978-20091030-00
./20091030_online_bu_copy_TS_UNDOTBS1-68kt3ngs
./20091030_online_bu_copy_TS_SYSAUX-69kt3nhl
./20091028_cf&spfile_NASMB_c-2956975978-20091028-03
./20091028_online_bu_copy_TS_SYSTEM-ipksumm4
./20091028_online_bu_copy_TS_UNDOTBS1-iqksumn7
./20091028_online_bu_copy_TS_SYSAUX-irksumo0
./20091030_online_bu_copy_TS_USERS-66kt3n25
./20091030_online_bu_copy_TS_SYSTEM-67kt3nfo
./20091029_cf_copy-v0kt1531.ctl
./20091029_cf&spfile_NASMB_c-2956975978-20091029-00
./20091029_online_bu_copy_TS_UNDOTBS1-o9kt1465
./20091029_online_bu_copy_TS_SYSAUX-oakt146u
./20091103_cf&spfile-AUTO_c-2956975978-20091103-01
./20091105_cf&spfile-AUTO_c-2956975978-20091105-00
./20091104_online_bu_copy_TS_SYSAUX-98kthi8g
./20091104_cf&spfile-AUTO_c-2956975978-20091104-02
./20091028_online_bu_copy_TS_USERS-ioksum8q
./20091104_online_bu_copy_TS_UNDOTBS1-97kthi7m
./20091029_online_bu_copy_TS_USERS-o7kt13mq
./20091029_online_bu_copy_TS_SYSTEM-o8kt144o
./20091103_cf_copy-pbktem96.ctl
./20091104_online_bu_copy_TS_SYSTEM-96kthi6j
./20091103_cf&spfile-AUTO_c-2956975978-20091103-00
./20091104_online_bu_copy_TS_USERS-95kthhov
./20091103_online_bu_copy_TS_SYSAUX-dkkted6f
./20091103_cf_copy-p9kteeo8.ctl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2009 08:06 AM
11-05-2009 08:06 AM
Re: find command with variables and *
Figured it out:
oracle@mbowodb1 NASMB> find . -type f -name "*${YESTERDAY}_*"
./20091104_online_bu_copy_TS_SYSAUX-98kthi8g
./20091104_cf&spfile-AUTO_c-2956975978-20091104-02
./20091104_online_bu_copy_TS_UNDOTBS1-97kthi7m
./20091104_online_bu_copy_TS_SYSTEM-96kthi6j
./20091104_online_bu_copy_TS_USERS-95kthhov
oracle@mbowodb1 NASMB> find . -type f -name "*${YESTERDAY}_*"
./20091104_online_bu_copy_TS_SYSAUX-98kthi8g
./20091104_cf&spfile-AUTO_c-2956975978-20091104-02
./20091104_online_bu_copy_TS_UNDOTBS1-97kthi7m
./20091104_online_bu_copy_TS_SYSTEM-96kthi6j
./20091104_online_bu_copy_TS_USERS-95kthhov
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP