01-09-2008
script for deletion using wildcards
find ./ -name t\* | sed "s@^./@@" > .filestobedeleted
j=$(wc -l < .filestobedeleted)
typeset -i cnt=0
typeset -i i=0
while read line
do
myarray[$cnt]=$line
((cnt = cnt + 1))
done < .filestobedeleted
while [ ${i} -le ${j} ]
do
file=${myarray[$i]}
destfile=$(basename ${file})
ABS_PATH=$(cd $(dirname ${file});pwd)
suffix=$ABS_PATH/${destfile}_$(date +%d%m%y%H%M%S)
timestamp=${suffix##*_}
echo $suffix >> $HOME/.trashinfo
mv -vi "$file" "$HOME/.trash/${destfile}_${timestamp}"
((i = i + 1))
done
in the first line , I have specified the input directly
instead we should receive the input which is generally using $1 as below but if I give the input as $1 it does not recognize t\*
there is something that needs to be done , kindly check
find ./ -name $1 | sed "s@^./@@" > .filestobedeleted
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have a folder with limited space. I do not have provisions to increase the space for this folder.
So i have to delete files which are more than 1 month old automatically.
But, i need to maintain the files created by 4 users and delete all the other files automatically which is more than 1... (4 Replies)
Discussion started by: vivek_scv
4 Replies
2. Shell Programming and Scripting
Hello
I have this script:
#!/bin/ksh
INPUTFILE=$1
TEMPFILE=$INPUTFILE.$$
OUTPUTFILE=$INPUTFILE.new
# nr of arguments has to be 1
if
then
echo "\nUsage: $0 inputfile\n"
return 1
fi
# inputfile must exist and be readable
if
then (13 Replies)
Discussion started by: emferrari
13 Replies
3. Solaris
Hi,
I have a folder with limited space. So i have to delete folder which are more than 5 days old automatically.
So my script should be like delete the folder more than 5 days old.
Can someone help me to generate a script for this.
Thank you...
Cheer
Summer (5 Replies)
Discussion started by: summerpeh
5 Replies
4. Shell Programming and Scripting
I've written a small static script for my log deletion, but I was wondering if there was a way to make it a dynamic script. here is how my script currently works.
#!/bin/sh
###########################################
#Script to zip logs older than 1 week old
#and to delete logs older than 30... (3 Replies)
Discussion started by: cbo0485
3 Replies
5. Shell Programming and Scripting
Good evening All,
I have a perl script to pull out all occurrences of a files beginning with xx and ending in .p. I will then loop through all 1K files in a directory. I can grep for xx*.p files but it gives me the entire line. I wish to output to a single colum with only the hits found. ... (3 Replies)
Discussion started by: CammyD
3 Replies
6. Shell Programming and Scripting
Ok, so I just got charged with the task of deleting some 300 user folders in a FTP server to free up some space. I managed to grep and cut the list of user folders to delete into a list of one user folder per line.
Example:
bob00
jane01
sue03
In the home folder, there are folders a-z, and... (5 Replies)
Discussion started by: b4sher
5 Replies
7. Shell Programming and Scripting
I saw many post about this but could not find a specific answer to this question.
i have the following code
find . -depth -name "$FILEEXT" -ctime -30 -exec rm {} \;
when i type ./deletefiles.sh *.txt for example, it will find all the txt files less than 30 days old and delete them.
my... (9 Replies)
Discussion started by: new2learn09
9 Replies
8. Shell Programming and Scripting
All printers are created on the PROD server and my script must pick up the differences in a diffs.txt file
delete the printer if exist on the DEV server
recreate it as it currently stands on the PROD server from the diffs.txt
The following script I have, should allow me in synching the local... (0 Replies)
Discussion started by: ggoliath
0 Replies
9. Shell Programming and Scripting
Does anyone know how I would go about inserting text at the beginning of a file with the file name containing a daily time stamp? Essentially I need to find the file name using a wild card, and then insert 3 lines of text - one of which is the processing date. Help please!? (1 Reply)
Discussion started by: cookie33
1 Replies
10. Shell Programming and Scripting
I have four files:
test
test2
test3
test4
I have this simple script:
#!/bin/bash
ls $1
Why does ./the_script.sh test* only list the first file, when a normal ls test* would list all four? What do I need to change in the script to be able to use wildcard? (12 Replies)
Discussion started by: KidCactus
12 Replies
LEARN ABOUT FREEBSD
ctfmerge
CTFMERGE(1) BSD General Commands Manual CTFMERGE(1)
NAME
ctfmerge -- merge several CTF data sections into one
SYNOPSIS
ctfmerge [-fgstv] -l label -L labelenv -o outfile file ...
ctfmerge [-fgstv] -l label -L labelenv -o outfile -d uniqfile [-g] [-D uniqlabel] file ...
ctfmerge [-fgstv] -l label -L labelenv -o outfile -w withfile file ...
ctfmerge [-g] -c srcfile destfile
DESCRIPTION
The ctfmerge utility merges several CTF data sections from several files into one output file, unifying common data.
The following options are available:
-f Match global symbols to global CTF data.
-g Don't delete the original debugging sections.
-s Use the .dynsym ELF section instead of the .symtab ELF section.
-t Make sure that all object files have a CTF section.
-v Enable verbose mode.
-l label
Sets the label as label.
-L labelenv
Instructs ctfmerge to read the label from the environment variable labelenv.
-o outfile
Use outfile to store the merged CTF data.
-d uniqfile
Uniquify against uniqfile.
-d uniqlabel
Uniquify against label uniqlabel
-w withfile
Additive merge with withfile.
-c srcfile destfile
Copy CTF data from srcfile into destfile.
EXIT STATUS
The ctfmerge utility exits 0 on success, and >0 if an error occurs.
SEE ALSO
ctfconvert(1), ctfdump(1)
HISTORY
The ctfmerge utility first appeared in FreeBSD 7.0.
AUTHORS
The CTF utilities came from OpenSolaris.
BSD
July 7, 2010 BSD