0
votes
1answer
31 views

How can I delete the oldest directory in a directory?

I am writing a backup programm, and I need to execute a bash command to delete the oldest directory in a specific directory. I have found this command to print the oldest directory: find -type f ...
2
votes
1answer
23 views

Can you delete all users but specified accounts in Ubuntu?

I am trying to find a way to quickly delete all user accounts except for the ones I specify in Ubuntu. Is there a good way of doing this? Perhaps a bash script that could do this function? I ...
2
votes
1answer
179 views

Delete all file except some in bash, without cd to the directory?

I need to make a daily cleanup in a download directory. I have saw this question and tested the answer rm !("test 1"|"test 4") It work great, but require to have cd to the directory before. Since ...
1
vote
2answers
157 views

rm -r: exclude certain subdirectories

The problem I have a directory structure, e. g. something like this (here trailing slashes represent folders): ./A ./B/A/A ./B/A/B ./B/B/ ./B/C ./C/ And I need to recursively remove everything ...
3
votes
3answers
250 views

Can't delete file with foreign letters

I have a file: På hjul.mkv When trying to move or delete file I get rm: can't remove 'På Hjul.mkv': No such file or directory The same thing happens when trying to issue $ rm *P* or the like: ...
4
votes
1answer
212 views

Diff between two directories and keep only the unchanged ones

I need to diff two directories: A: /path1/ B: /path2/ The directory A contains all files and subdirectories that are also contained in B. The files in A (and in its subdirectories) can have ...
2
votes
2answers
1k views

bash home/end/delete key inserting tilde, or if preceded by escape key, [1~ [3~

bash home/end/delete key inserting tilde, or if preceded by escape key, [1~ say I type echo hellp, move cursor to hel|lp and type delete, and bam, i got ~tilde say I type echo hellp, move cursor to ...
-3
votes
1answer
113 views

How can I delete files that have a size of 0 in bash? [duplicate]

Possible Duplicate: Bash Find Files with zero size and delete files with different extensions How can I delete files that have a size of 0 in bash?
2
votes
1answer
4k views

Delete all files inside a directory over FTP with BASH

I try to delete all files from a directory on a remote FTP server with BASH. I was only able to delete the files and the folder, but not just clearing a folder out.. :/
2
votes
2answers
637 views

How do you make zsh meta-delete behave like bash? (To make it delete a word instead of the entire path.)

Bash's meta-delete will remove one path component instead of the entire path. How do you get zsh to behave like that? I found this, which seems to work. Is this the right thing to do? One of the ...
1
vote
3answers
316 views

Script to keep specific directories that contains a .txt file and deletes the files from the other directories without the specific .txt file

I am almost done with the script but this outputs directories. What I would like is to have an output of files. Anyway one of you guys wanna help me out? :) #!bin/bash ( find /testftp/* -type d ; ...
3
votes
1answer
1k views

Accidentally deleted .bashrc file in Ubuntu 11.04

I just installed Ubuntu and accidentally deleted .bashrc file in Ubuntu 11.04 Is there a way to recover it or a default one?
6
votes
5answers
12k views

Bash script to keep last x number of files and delete the rest

I have this bash script which nicely backs up my database on a cron schedule: #!/bin/sh PT_MYSQLDUMPPATH=/usr/bin PT_HOMEPATH=/home/philosop PT_TOOLPATH=$PT_HOMEPATH/philosophy-tools ...
2
votes
1answer
923 views

Bash auto-delete script

I'm looking for a bash script that would auto-delete oldest folders (lets say last 3) in a directory when the available space drops below X gigs. Any ideas? *Ive red related posts but since I don't ...
2
votes
3answers
404 views

How to use “rm” to remove files with a “:” in them?

I am using Ubuntu 10.04, and I have a directory with a bunch of files. We changed the naming scheme of the files a while ago, and now I want to delete all the old ones. New Name scheme: ...
1
vote
2answers
786 views

Why can't certain files on my external drive be deleted with Unix utilities?

I have an external drive (WD My Book World) mounted on my Ubuntu system which I've used for backups over the last few years. Some of the backups included SVN repositories which now include files ...