Hi,
I want to write a script that deletes all folders and keep the last 10 recent folders.
I know the following:
ls -ltr will sort the folders from old to recent.
ls -ltr | awk '{print $9}' will list the folder names (with a blank line at the beginning)
I want to get the 10th folder from... (3 Replies)
I do not know much about shell scripting so I am at a loss here. If someone can help me, that would be great!
I have two directories
/dir1
/dir2
I need to delete all files from /dir1 and that does not have a correspondent file in /dir2. It should NOT check file suffixes in /dir2 . Why?... (20 Replies)
I need some help writing a simple script that will delete all subfolders that contain no mpg or nuv files, if they have anything else or are empty the folder should be deleted
I got this far but I'm pretty hopeless
foo=0
if
then
foo=1
fi
if
then
foo=1
fi
if
then
echo found... (9 Replies)
Folks,
I am hopeful that you may be able to help me out with writing a script that can be run nightly (as cron?) to loop through all subfolders within the "/media" directory, delete all of the files in each of them, and then copy in all of the files from the "/home//sansa" directory to each of... (6 Replies)
I have a requirement to delete the files and folders under a given directory.
my directory structure is like this..
Data
|
A(Directory)
|_PDF(Directory)----pdf files
|_XML()Directory --xml files
|--files
|
B(Directory)
|_PDF(Directory)----pdf files
|_XML()Directory --xml files ... (1 Reply)
Hi All,
Let me know how can i find and delete files from one unix server to another unix server which are 'N' days older.
Please note that I need to delete files on remote unix server.So, probably i will need to use sftp, but question is how can i identify files and folders which are 'N'... (2 Replies)
Hi Everyone,
I work for GE Money IVR as a DB analyst and the environment on which I work is Solaris 5.0 server and Oracle 11g.
I got a project in which I have to clean up the folders and files which are not used in DB.
I copied an existing script and edited it, dont know this is the... (5 Replies)
Hi
I am new to Linux / scripting language. I need to improve our Linux servers at work and looking to claim some space my deleting log files/ folders on a 5 day basis.
Can someone help me with creating a script to do so.
Any sample script will be helpful.:b:
Regards (2 Replies)
Hello, my first thread here.
I've been searching and fiddling around for about a week and I cannot find a solution.:confused:
I have been converting all of my home videos to HEVC and sometimes the files end up smaller and sometimes they don't. I am currently comparing all the video files... (5 Replies)
Discussion started by: Josh52180
5 Replies
LEARN ABOUT V7
find
FIND(1) General Commands Manual FIND(1)NAME
find - find files
SYNOPSIS
find pathname-list expression
DESCRIPTION
Find recursively descends the directory hierarchy for each pathname in the pathname-list (i.e., one or more pathnames) seeking files that
match a boolean expression written in the primaries given below. In the descriptions, the argument n is used as a decimal integer where +n
means more than n, -n means less than n and n means exactly n.
-name filename
True if the filename argument matches the current file name. Normal Shell argument syntax may be used if escaped (watch out for
`[', `?' and `*').
-perm onum
True if the file permission flags exactly match the octal number onum (see chmod(1)). If onum is prefixed by a minus sign, more
flag bits (017777, see stat(2)) become significant and the flags are compared: (flags&onum)==onum.
-type c True if the type of the file is c, where c is b, c, d or f for block special file, character special file, directory or plain
file.
-links n True if the file has n links.
-user uname
True if the file belongs to the user uname (login name or numeric user ID).
-group gname
True if the file belongs to group gname (group name or numeric group ID).
-size n True if the file is n blocks long (512 bytes per block).
-inum n True if the file has inode number n.
-atime n True if the file has been accessed in n days.
-mtime n True if the file has been modified in n days.
-exec command
True if the executed command returns a zero value as exit status. The end of the command must be punctuated by an escaped semi-
colon. A command argument `{}' is replaced by the current pathname.
-ok command
Like -exec except that the generated command is written on the standard output, then the standard input is read and the command
executed only upon response y.
-print Always true; causes the current pathname to be printed.
-newer file
True if the current file has been modified more recently than the argument file.
The primaries may be combined using the following operators (in order of decreasing precedence):
1) A parenthesized group of primaries and operators (parentheses are special to the Shell and must be escaped).
2) The negation of a primary (`!' is the unary not operator).
3) Concatenation of primaries (the and operation is implied by the juxtaposition of two primaries).
4) Alternation of primaries (`-o' is the or operator).
EXAMPLE
To remove all files named `a.out' or `*.o' that have not been accessed for a week:
find / ( -name a.out -o -name '*.o' ) -atime +7 -exec rm {} ;
FILES
/etc/passwd
/etc/group
SEE ALSO sh(1), test(1), filsys(5)BUGS
The syntax is painful.
FIND(1)