CentOS 5 :: Command To Delete The Oldest File In A Folder/directory?
Oct 13, 2009
I am trying to add a command to my backup script to delete the oldest file in the destination folder before adding a new .tar.gz file.I found this information at .html which I thought would work fine and added the following line to my backup script:ls -t -r -l /backups/Scalix_Backup* | head --lines 1 | xargs rmHowever when I tried this I get an error:rm: invalid option -- wTry `rm --help' for more information
I have a directory listing with many subdirectories having many files. I want to recursively search for the oldest 5 files starting from the base directory and not 5 from each subdirectory. I am writing a shell script which sorts them using ls -lRtur|egrep "txt|jpg" > /tmp/file1 Now from this /tmp/file1 file I want to sort the files same as what the ls -ltr command does that is oldest file time to newest file time first. How do I sort based on Linux time stamp? The files itself also have Linux timestamps embedded in them So I can sort based after extracting them as well if it is easier. My /tmp/file1 has entries like below.
Recently I setup a system for a non-technical user. He is only using Firefox, Pidgin and OpenOffice for about 2 hours a day. I have created a folder "/home/jim/myFiles" where he can save his document files. But Jim has accidentally deleted his myFiles folder on 2 occasions. He had intended to delete a file in that folder. Is there a way to lock the folder so that the user and create/read/write documents in that folder but not delete the folder itself?
I wanna delete a directory with its files and I wanna do that as follows: rm -r dirToDelete Unfortunately, I always get asked for EACH single file if I wanna delete this because it is write protected.... Is there a way to suppress this feedback message so that just the whole directory with its contents disappears?
I am running the latest version of Ubuntu (Ubuntu 11.04) which i setup as a dual boot OS with Windows XP SP3. I was listening to my MP3s using the Banshee music player on Ubuntu. My MP3s reside on an NTFS drive (which I mounted in Ubuntu to hear the MP3s). Via the Banshee player I deleted all songs from a particular folder and thought nothing of it until I later booted into Windows.
I saw the folder that had the songs I had deleted the songs and and thought I'd delete the folder as well except that I couldn't. It said the file might be corrupted. I logged backed into Ubuntu (Windows XP was shutdown not hibernated as I remember hearing that on Hibernating, you can't properly delete/copy files on Windows partitions). In Ubuntu too, I wasn't able to delete this folder - either via the Folder explorer or via terminal. I see a file named ".fuse_hidden0000041b00000017" along with some other files I had deleted (in Turquoise colour). I didn't see any posts in this forum with a help on resolving this issue
I was transferring some files from my laptop (running FC6) to a server at my work (don't know what kind) with "scp -rpC" and it stalled, don't know why. Now when I try to delete the files from the server so I can start again I get the following error message
Directories(-entries) are in a EXT2 file system managed in a singly linked list. Delete files in the directory causes Gaps or holes to appear in the linked list of the directory.How does a C-source code look like, which would reorganize this list and remove the gaps or Holes.
SO after using Testdisk to recover some images, the folders recup_dir.1 & 2 have saved in my FIle System area, when ever I try to press delete noting happens. I have also tried rm -f -rrm -f -fIt still dont delete, I have also deleted my user account and made a new one, but the files are still there.
I'm using ubuntu server 9.10 for a home build NAS. Everything is working great just have one more thing to figure out. I have Samba set up to access my files and I set up a recycle feature so anything deleted will get moved to a Recycled folder. (I learned this the hard way after hitting delete key by accident while browsing the shares in windows. Lost 100 GB of data)
Now it is for the most part working but the permissions on folders isn't getting set right. If I delete a file in a share I can go to Recycle bin folder and delete the file for good. But if I delete a folder I can not access that folder to delete or restore from the Recycle bin folder. I have to chmod the folder before I can do anything with it. Anything I can change to get folders deleted via windows to have the right permissions when it is moved to the Recycle bin folder?
I have Ubuntu Jaunty 9.04 updated to 9.10 and have downloaded Remaster from Remastersys. I followed all of the instructions, which were simple enough. However, there must be some instructions missing as the process failed. Working with Remaster through Synaptic Manager, the iso was downloaded into my "home" folder into its own Remaster folder. It was not the iso, like you get when downloading a distro from the Internet, which downloads just an iso onto the Desktop. Inside the folder were a bunch of empty files (I know, because I opened them) and an iso . At this point the Remaster instruction stop. They do not say what to do with the other files, or what they have to do with the iso of my Ubuntu layout. So, like any other iso (once I knew which one was the iso of my setup), I double clicked on it and it ran me through the process of accessing the DVD to burn it. Which I did. I tested it and it failed with some kind of message to the effect that certain files were missing or it could not read it. So, I thought, I would have to do the 'hunt and peck' method and experiment a few times like I did with the ordinary distro downloads until I get it right. But first, I would have to dump the Remaster folder in the "home" folder since it took up so much space on my hard drive. Wrong! I come to find out it is in something called "root" and that I do not have permission to do anything with it but "copy" it. Great. Just great! Now what do I do. I tried to change permissions, but was not allowed to do that either. The only thing I could think of - and dread - was the idea of having to wipe my hard drive and go through the whole reinstall procedures, which takes me days, just because Remaster has locked itself into my system - and there is no 'back door' to get out of it.
I'm having trouble finding the correct modifiers to the stat command to print out the file/folder properties in human readable format. I would like to run a command on a given file or folder and have the file size in kb, mb, or gb size as opposed to byte size in addition to other pertinent information.
I have just installed the 32bit and 64bit versions of CentOS 5.5 and was wondering how I can add these machines to Active Directory for authentication. I've done this in the past with CentOS 5.4 using the GUI and everything worked just fine but now need to do everything from the command line.
I am trying to install iscsi-target on centos 5.4 i386. When I go into the iscsi-target directory and type make I get the following error: [root@cluster-storage iscsitarget-1.4.19]# make cc: /lib/modules/2.6.18-164.el5/build/include/linux/version.h: Datei oder Verzeichnis nicht gefunden cc: keine Eingabedateien /bin/sh: line 0: [: -le: unary operator expected /bin/sh: line 0: [: -le: unary operator expected /bin/sh: line 0: [: -le: unary operator expected /bin/sh: line 0: [: -le: unary operator expected /bin/sh: line 0: [: -le: unary operator expected /bin/sh: line 0: [: -le: unary operator expected /bin/sh: line 0: [: -le: unary operator expected /bin/sh: line 0: [: -le: unary operator expected /bin/sh: line 0: [: -lt: unary operator expected make -C usr make: Entering directory `/opt/iscsitarget-1.4.19/usr' ..... make: *** [kernel] Fehler 2