HI Everyone, need a shell script which checks size of a directory and if it gets greater than 1 GB then delete all the files in it.
ex: dir : /var/log/
/log contains numerous .log files, so script should delete .log files always when /log size is greater than 1 GB , it should not delete the directory
Hi,
I'm wondering if anyone can help me make a script that searches through a specific folder (in this case /tmp ) for files with a given permissions (755) and then delete all the other files with different permissions?
The correct permission should be, as mentioned 755, and those are the files that should be kept (not deleted).
All other files in this folder with different permissions should be deleted.
Thanks!
I have serveral nodes related files under /var/lib/ directory as shown below:
Code:
machine001.cluster.org
machine002.cluster.org
machine003.cluster.org
machine004.cluster.org
I am trying to write a shell script which first finds out how many number of files are present in this directory. Then it should fetch the first name like machine001, machine002, machine003 etc. Then it should fetches ipaddress, hostname and netmask under machine001 first, then store it in some variable. Repeat this for all the nodes. How will the script look like?
I'm trying to figure out if find could do this. I have a folder with 1000 files. I want to delete 150 files on that folder regardless of timestamp and filename. Is there a tool, command or option on find that could do this, please let me know.
Combining mtime or ctime to find is not advisable since it will not count the files or even if there are matches, I would still need to sum up the files until I reach 150 files.
Any suggestions?
Hi Experts,
Is there a way that i can delete selected directory trees on sftp server. Directory is only getting removed if it is empty. I am able to sftp & scp on the server to transfer the files.
Please help here!
VijayB
Hi
I have a folder :
Code:
/usr/local/src/myfolder
and i have there a few folders and files ...
Now i want to delete from this folder the files named:
Code:
file1.txt
image.jpg
info.html
another.txt
and leave all the rest folders and files...
How is the correct syntax for this?
If it is possible to not use cd /usr/local/src/myfolder and then rm -r .... so i can run it from everywhere ....
Thanks
I would like to tar up some system logs with core files as a normal user through a script. However these core files are owned by root.
Of course I get "cannot read directory ...: Permission denied"
Is there a good way to grab these core files through a script? From searching around, I get that the best way is to modify the sudoers file, then run the script with sudo. Is this considered the safest and best way?
Thanks!
Hi,
I am looking for a simple shell script that allows for sftp to be run from the server to another server (Windows). I would like the script to be passed parameters suchas destination server, Id, password, Directory structure/folder name, file name etc...
Need some help to know how to start with and it would be great if someone help me with any sample sftp shell script
books say that PATH variable contains the locations where the shell searches the commands to execute them.
I created a shell script and saved it in /home/user/Downloads directory and then i ran this script from the /home/user/Downloads directory. It did not execute.
however when i did set the path
export PATH=$PATH:/bin/sh within /home/user/Downloads directory, the shell script executed. Does it not mean that PATH variable is holding the locations of the shell program rather than the commands that are to be executed?
everytime i have to give the location of the shell i.e /bin/sh in the PATH variable no matter from where i am executing my script
Have installed Xubuntu with /home on second hard drive. If I change to a different distribtuion such as Mint Mate do I have to delete all the hidden files in my home directory?
I'm in the need of building a script to clean up my media library. I've been PVR'ing for years now and it's time to clean things up. For example, my TV Shows are saved as such:
/media/storage/Show Name/Season 1/Show Name - S01E01 - Episode Name.mp4
Over the years I've created a bunch of subdirectories further than that and I want to go through and clean those out. For example, the following directory might exist:
/media/storage/Show Name/Season 1/subtitles
If I use the find command, with -type d and -maxdepth 4, I have discovered that the subdirectory I want to delete is in the 4th level. There should be nothing valid in the 4th level and okay to delete.
I don't really know where to start. I tried using the find command with -mindepth 4 but that doesn't seem to work as I would expect. Basically, I want to scan through the library, then I want to test to make sure that the directory isn't "Season XX" and if it is a subdirectory within Season X then I would like to delete that subdirectory.
Any ideas how I can accomplish this?
FYI: I'm using Korrora 21 with BASH.