Delete Directories and its files that begin with the same character string
I wrote a shell script program that supposed to delete any directories and its files that begin with the same character string . The program is designed to delete directories and its files that are one day old or less and only the directories that begin with the same character string. The problem is the program doesn't delete the directories. I don't know why the script isn't working. The OS is Linux redhats. Version 6 x.
Here is the shell script
Below are sample of the directories that the program should delete if the directories are one day old or less.
Last edited by Scrutinizer; 07-16-2019 at 01:11 PM..
Reason: quote tags -> code tags
Hi ! All,
I have to delete first 2 characters from string. How its possible?
Like string value is "2001". I required output as "01"
Plaese help me.
Nitin (4 Replies)
Hello friends,
I am compiling some set of SQL scripts in a set of sub directories demoed as below. After compiling log files are being created.
Each and every time after compiling time I had to go subdir by subdir to delete the log files. I am sure there should be simple way to look for all log... (4 Replies)
Can any one please help me in deleting all the Files over 7 days from sub-directories A, B, C...
Top-Directory
Sub-Directory-A
File-1
File-2
.....
File-n
Sub-Directory-B
File-1
File-2
.....
File-n
Sub-Directory-C
File-1
... (1 Reply)
I would like to remove characters from column 7 so that from an input file looking like this:
>HWI-EAS422_12:4:1:69:89 GGTTTAAATATTGCACAAAAGGTATAGAGCGT U0 1 0 0 ref_chr8.fa 6527777 F DD
I get something like that in an output file:
... (13 Replies)
Hello all,
I have a file containing the following
p1 q1 p2 q2 p1 p2 p3
pr1 pr2 pr1 pr2
pa1 pa2
I want to remove the last character from all strings that start with 'p' and end with '1'. In general, I do not know what is between the first part of the string and the last part of the string.... (4 Replies)
Hallo!
Example.
#!/bin/bash
BACKUP_DIR=/home/userx/backups/evolution
echo $BACKUP_DIR
# delete the first character from the string
BACKUP_DIR=$(echo $BACKUP_DIR | cut -c 2-)
echo $BACKUP_DIR
It works. It does want I want, delete the first character from string in the... (11 Replies)
I have a task, I usually do manually, but with growing responsibilities I tend to forget to do this weekly, I want to write a script that automates this, but I cant seem to work it out in my head, I have the shell of it out, but need help, and you guys have helped me with EVERY problem I have... (5 Replies)
OS: SUNOS 5.10 i386
Hello guys I wrote a shell script in bash shell to delete the files less than 30 days old. The following is the script.
=======================================
#!/bin/bash
for dirs in `/clu04/oracle/directory_list.lst`
do
find $dirs -type f -mtime -30 -exec rm {} \;... (3 Replies)
Hello,
i have an dynamical apache_cache that I need to clean all days (older tant one day) with an unix command :
find /usr/IBM/HTTPServer/apache_cache/ -name '*' -mtime +1 -print0|xargs -0 rm -r --
but it didn't work.
Could you explain me why.
So I will put below all my script :... (13 Replies)
guys, i did create a script but its too long, though it function the same.
# cat nightlyscan.sh
#!/usr/ksh
deyt=`date +"%Y-%m-%d"`
for i in `ls -lrt|grep $deyt|awk '{print $9}'`
do
cp -f $i /S1/Sophos/logger/
done
#
but i did not paste it all.
this is the desired. (9 Replies)
Discussion started by: kenshinhimura
9 Replies
LEARN ABOUT LINUX
initscript
INITSCRIPT(5) Linux System Administrator's Manual INITSCRIPT(5)NAME
initscript - script that executes inittab commands.
SYNOPSIS
/bin/sh /etc/initscript id runlevels action process
DESCRIPTION
When the shell script /etc/initscript is present, init will use it to execute the commands from inittab. This script can be used to set
things like ulimit and umask default values for every process.
EXAMPLES
This is a sample initscript, which might be installed on your system as /etc/initscript.sample.
#
# initscript Executed by init(8) for every program it
# wants to spawn like this:
#
# /bin/sh /etc/initscript <id> <level> <action> <process>
#
# Set umask to safe level, and enable core dumps.
umask 022
ulimit -c 2097151
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
# Increase the hard file descriptor limit for all processes
# to 8192. The soft limit is still 1024, but any unprivileged
# process can increase its soft limit up to the hard limit
# with "ulimit -Sn xxx" (needs a 2.2.13 or later Linux kernel).
ulimit -Hn 8192
# Execute the program.
eval exec "$4"
NOTES
This script is not meant as startup script for daemons or somesuch. It has nothing to do with a rc.local style script. It's just a handler
for things executed from /etc/inittab. Experimenting with this can make your system un(re)bootable.
FILES
/etc/inittab, /etc/initscript.
AUTHOR
Miquel van Smoorenburg ,<miquels@cistron.nl>
SEE ALSO init(8), inittab(5).
July 10, 2003 INITSCRIPT(5)