- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- cp command with regular expressions
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
Discussions
Discussions
Discussions
Forums
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
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-25-2006 09:21 PM
тАО09-25-2006 09:21 PM
I have files with the following naming format:
measlog0, measlog2, measlog3, measlog4, measlog5, measlog6, measlog7, measlog8, measlog9, measlog10, measlog11.
I'd like to copy these files to different directory, using "cp" command with some regular expressions:
1) cp measlog[0-9]* /tmp/testdir
This option works well if there no other characters after the filename measlog
I attempted a more secure method, but did not work:
bash-2.05$ cp measlog[0-9]*$ /tmp/testdir
cp: cannot access measlog[0-9]*$
bash-2.05$ cp measlog[0-9]{2} /tmp/testdir
cp: cannot access measlog[0-9]{2}
Could anyone show how I could use a more "secure" regular expression within "cp" to ensure files like measlog0, measlog1 ... measlog11 (i.e. measlog
Thanks
Danny
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 09:36 PM
тАО09-25-2006 09:36 PM
Re: cp command with regular expressions
and this :
cp measlog?? /tmp/testdir
could meet your needs?
hth
regards
pg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 09:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 09:43 PM
тАО09-25-2006 09:43 PM
Re: cp command with regular expressions
or try
cp measlog[0-90-9] /tmp/testdir
Regards
pg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 09:47 PM
тАО09-25-2006 09:47 PM
Re: cp command with regular expressions
Try:
for fn in measlog*
do cp $fn /tmp/testdir
done
Regards,
Yang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 11:05 PM
тАО09-25-2006 11:05 PM
Re: cp command with regular expressions
cp measlog[0-9] measlog[0-9][0-9] /somedir
As always, test the list with echo first:
echo cp measlog[0-9] measlog[0-9][0-9] /somedir
cp knows nothing about regular expresions (or more accurately, filename generation) so the echo will show you what cp will see.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-26-2006 09:25 PM
тАО09-26-2006 09:25 PM
Re: cp command with regular expressions
can you please update with any feedback.
If the problem is resolved, could you please identify the solution, rewards any helpful answers and close the thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2006 06:41 PM
тАО09-27-2006 06:41 PM
Re: cp command with regular expressions
Issue resolved by using the method suggested by Peter, i.e.:
cp measlog*[0-9] /tmp/testdir
Thank you all for your help.