- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script shell
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
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
тАО11-13-2002 07:40 AM
тАО11-13-2002 07:40 AM
help me please,
I get the script that list contents of dir, but I need to limit by number of files.
In other words:
I have 10 files in /ttp,
I want to move only the last 5 new. I'm using sh, but can be csh ou ksh.
Thanx in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2002 07:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2002 07:54 AM
тАО11-13-2002 07:54 AM
Re: script shell
do
mv $F wherever
done
Regards,
John
- Tags:
- mv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2002 07:54 AM
тАО11-13-2002 07:54 AM
Re: script shell
Ex:
a b c d e f g h
list only: a b c d e
f g and h are the new...
thanx...!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2002 07:55 AM
тАО11-13-2002 07:55 AM
Re: script shell
Use 'ls -t' to present your list of files sorted by the modification time (latest first) before sorting alphabetically. Then count off the first five entries and do your processing using only them.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2002 07:56 AM
тАО11-13-2002 07:56 AM
Re: script shell
#!/usr/bin/sh
for file in $(ls -t /ttp|head -5)
do
# do your move here
done
I'm assuming in /ttp there are only files, no directories.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-14-2002 02:10 AM
тАО11-14-2002 02:10 AM
Re: script shell
the last script is:
#!/usr/bin/sh
NR=`ls /dir1/*.fff|wc -l` # total
LI=5 # don't touch this
MV=`expr $NR - $LI`
VS=/dir1
VS2=/dir2
export VS VS2 NR LI MV
echo $NR, $LI, $MV
if [ "$NR" -gt "$LI" ] # > LI files ?
then
for file in $(ls -rt $VS/*.fff|head -$MV)
do
mv $file $VS2
done
fi
Thanx to everyone.
Lima.