![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting latest file from ftp | arunavlp | UNIX for Dummies Questions & Answers | 3 | 02-08-2008 06:19 AM |
| latest Unix | irfanets | UNIX for Dummies Questions & Answers | 7 | 07-28-2007 10:24 PM |
| latest unix | irfanets | UNIX for Advanced & Expert Users | 1 | 07-27-2007 04:26 AM |
| latest version of bsd | chilaka | BSD | 1 | 12-18-2006 04:24 AM |
| get latest file | inquirer | Shell Programming and Scripting | 3 | 07-06-2003 09:44 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Move all but not the latest
what is way to not move a latest file in a a particular folder X.
There are number of files in the folder, I donot want to move the latest file into another folder. Can anyone figure out where is wrong in the script. Code:
lastfile=$(ls -rt | tail -1)
for allfile in $(ls | grep -v |$lastfile)
do
echo > $allfile
mv <all existing file> X
done
|
| Forum Sponsor | ||
|
|
|
|||
|
ls -rt | sed '$d' | xargs -I{} mv {}
Thats true
I am inside the folder Y inwhich folder X is there. all files are there inside the Y and want to move into X pwd return Y I am executing in this folder only. Code:
ls -rt | sed '$d' | xargs -I{} mv {} X
mv: cannot rename archive to X/X: Invalid argument Then what should be best way to move these into Y can you suggest ..do I need to call this from top folder ie above X and Y |