- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Case Statement Help needed
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
09-23-2009 02:29 PM
09-23-2009 02:29 PM
/home/abcd/test has 10 files
/home/abcd/dev has 10 files.
The naming convention of files is five digit,date.txt example: 12345.09232009.txt and so on.
Can someone help me in writing a case statement where it will have the logic to read files from test or dev directory and upload as necessary.
I was thinking along the following lines:
upload_dir_test=/home/abcd/test
upload_dir_dev=/home/abcd/dev
case $1 in
-u)
case $upload_dir_test in
12345)
upfile="12345*.txt"
;;
Could someone help me guide to the best way of doing this?
Thanks in advance.
Solved! Go to Solution.
- Tags:
- case
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2009 02:44 PM
09-23-2009 02:44 PM
Re: Case Statement Help needed
If the same naming convention is used in both directories then there is no test. Right now you have
12345......txt for both dev and test - what is the distinction? The directory names? Just the dir. names?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2009 03:00 PM
09-23-2009 03:00 PM
Re: Case Statement Help needed
See if this helps:
#!/usr/bin/sh
typeset upload_dir_test=/tmp/TST
typeset upload_dir_dev=/tmp/DEV
case $1 in
-t )
cd ${upload_dir_test} || exit 1
;;
-d )
cd ${upload_dir_dev} || exit 1
;;
* )
echo "bad option"; exit 1
;;
esac
upfile=$(ls -1 [0-9][0-9][0-9][0-9][0-9]*.txt 2>/dev/null)
echo ${upfile}
exit 0
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2009 06:08 PM
09-23-2009 06:08 PM
Re: Case Statement Help needed
/home/abcd/test/17648.09232009.txt
/home/abcd/test/24901.09232009.txt
/home/abcd/test/89012.09232009.txt
/home/abcd/test/28943.09232009.txt
/home/abcd/test/14567.09232009.txt
/home/abcd/test/90284.09232009.txt
/home/abcd/test/80010.09232009.txt
/home/abcd/test/13456.09232009.txt
/home/abcd/test/39284.09232009.txt
/home/abcd/test/29940.09232009.txt
/home/abcd/dev/17648.09232009.txt
/home/abcd/dev/24901.09232009.txt
/home/abcd/dev/89012.09232009.txt
/home/abcd/dev/28943.09232009.txt
/home/abcd/dev/14567.09232009.txt
/home/abcd/dev/90284.09232009.txt
/home/abcd/dev/80010.09232009.txt
/home/abcd/dev/13456.09232009.txt
/home/abcd/dev/39284.09232009.txt
/home/abcd/dev/29940.09232009.txt
And I am trying to have separate logic for DEV and TEST.
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2009 12:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2009 02:01 AM
09-24-2009 02:01 AM
Re: Case Statement Help needed
12345) upfile="12345*.txt"
I'm not sure what you want to do here.
If you want to upload all files with the pattern: [0-9][0-9][0-9][0-9][0-9].[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].txt
Then you can simply use ls to find them:
ls $upload_dir_test/[0-9][0-9][0-9][0-9][0-9].[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].txt
Or you can use grep after ls:
ls $upload_dir_test | grep "[0-9]\{5\}\.[0-9]\{8\}\.txt"