- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Move duplicate files to hold directory
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
тАО03-16-2009 05:14 AM
тАО03-16-2009 05:14 AM
Move duplicate files to hold directory
Please check the script,
The list of files is
ab.5890.20090311130443
ab.6065.20090311214416
ab.5890.20090311124512
ab.6065.20090311212449
ab.5891.20090311124512
#!/bin/ksh
for fls in `ls -1 /data/Syed/ab/ab*`
do
sqn=`echo $fls|cut -d"." -f2`
if [ `ls /data/Syed/ab/ab.$sqn.* | wc -l` -gt 1 ]
then
mv ab*.$sqn.* hold/
fi
done
The result is :
Moving: ab.5890.20090311124512 ab.5890.20090311130443
Moving: ab.5890.20090311124512 ab.5890.20090311130443
Moving: ab.6065.20090311212449 ab.6065.20090311214416
Moving: ab.6065.20090311212449 ab.6065.20090311214416
Just i need to check the files of same sequence and compare the size of same seqence files and move file which has small in size to hold directory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-16-2009 07:01 PM
тАО03-16-2009 07:01 PM
Re: Move duplicate files to hold directory
An easy way would be to check just before you run the mv.
Hi all,
Please check the script,
The list of files is
ab.5890.20090311130443
ab.6065.20090311214416
ab.5890.20090311124512
ab.6065.20090311212449
ab.5891.20090311124512
#!/bin/ksh
for fls in `ls -1 /data/Syed/ab/ab*`
do
sqn=`echo $fls|cut -d"." -f2`
if [ `ls /data/Syed/ab/ab.$sqn.* | wc -l` -gt 1 ]
then
SMALLER='ls -l | grep -v total | awk '{ print $5 " " $9 }' | sort -rn | tail -1'
mv $SMALLER hold/
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-16-2009 07:04 PM
тАО03-16-2009 07:04 PM
Re: Move duplicate files to hold directory
So I awk out the size and filename
sort this based on size and reverse it so that the smallest file is output last, then tail -1 gives the last File.
NOTE: you will need a further awk '{ print $2 }' at the end like so:
SMALLER=$(ls -l | grep -v total | awk '{ print $5 " " $9 }' | sort -rn | tail -1 | awk '{ print $2}' )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-16-2009 10:27 PM
тАО03-16-2009 10:27 PM
Re: Move duplicate files to hold directory
If you see the result the output is repeatinf twice and first move works fine but on seconf move it is giving error that "file move error" because files already moved to hold directory.
ab.5890.20090311124512 ab.5890.20090311130443
when iam using your new added line
SMALLER=$(ls- l | grep -v total | awk '{ print $5 " " $9 }' | sort -rn | tail -1 | awk '{ print $2}' )
Message is coming:
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2
and finally it is moving "Find_dupl_files.sh" script because it is small in size but i need to move the files from the list which is having same sequence and smaller in size mentioned in my previous mail.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-16-2009 11:04 PM
тАО03-16-2009 11:04 PM
Re: Move duplicate files to hold directory
This works fine, Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-16-2009 11:05 PM
тАО03-16-2009 11:05 PM
Re: Move duplicate files to hold directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-17-2009 04:17 AM
тАО03-17-2009 04:17 AM