- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: list the file need for syntex
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
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
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
10-16-2012 10:14 AM - last edited on 10-17-2012 06:55 PM by Cathy_xu
10-16-2012 10:14 AM - last edited on 10-17-2012 06:55 PM by Cathy_xu
list the file need for syntex
i want to list the file from 1_11_data01.dbf to 1_78_data01.dbf
and i need to copy the same file to some other location. please advise the command
1.list command
2.copy command
example file name
1_10_data01.dbf
1_11_data01.dbf
1_12_data01.dbf
1_13_data01.dbf
1_14_data01.dbf
1_15_data01.dbf
1_16_data01.dbf
1_17_data01.dbf
1_18_data01.dbf
1_20_data01.dbf
.
.
.
1_300_data01.dbf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2012 10:24 AM
10-16-2012 10:24 AM
Re: list the file need for syntex
if they are not in the same directory.
find $pathwherethefilesare -name 1_\*_data01.dbf -exec cp {} targetdir \;
or:
find $pathwherethefilesare -name 1_\*_data01.dbf >/tmp/listfile
cp $(cat /tmp/listfile) targetdir
or many other
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2012 12:37 PM
10-16-2012 12:37 PM
Re: list the file need for syntex
If you want to list that specific range of file, you can do something like:
ls 1_[1-7][0-9]_data01.dbf
This will give you all files in the range 1_10_data01.dbf through 1_79_data01.dbf.
You can use the same syntax with the brackets in a 'cp' command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2012 11:59 PM
10-16-2012 11:59 PM
Re: list the file need for syntax
>I want to list the file from 1_11_data01.dbf to 1_78_data01.dbf
If you only want these and not the edges given by Patrick's regex slice, then you need a script. Or use grep to remove the 3 files that you don't want.
list_data_files.sh:
#!/usr/bin/ksh
# Lists files from 1_11_data01.dbf to 1_78_data01.dbf
(( index = 11 ))
while (( index <= 78 )); do
if [ -f 1_${index}_data01.dbf ]; then # check if there
echo "1_${index}_data01.dbf \c"
fi
(( index += 1 ))
done
Then to list or cp you can use:
ls $(list_data_files.sh)
cp $(list_data_files.sh) targetdir
>cp $(cat /tmp/listfile) targetdir
So close, you left an evil cat there. ;-)
cp $(< /tmp/listfile) targetdir
- Tags:
- evil cat