Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User states number of files to move

Status
Not open for further replies.

maxcrook

Programmer
Jan 25, 2001
210
GB
Hi

I need a script that moves a number of files from one dir to another eg.

/mcrook/files/stuff

to

/mcrook/files

The user need to prompted to move n amount of files, the script then will only move n amount.

The files all begin with I but are unique in the rest of their format.
 
You don't specify which files to move, oldest, newest, alphabetically, etc. I use the ls command below, you can add the appropriate parameters to sort as desired.

Try this,
--------------------------------------------------
#!/bin/ksh
FROMDIR=/mcrook/files/stuff
TODIR=/mcrook/files

print "How many files to move?"
read NUM

mv `ls $FROMDIR\I* | head -$NUM` $TODIR
----------------------------------------------------
 
Thanks that is just what I needed - I do not need to specify the oldest, newest, alphabetically etc as they come in daily can always be processed in order.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top