Deleting the file in a folder


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Deleting the file in a folder
# 1  
Old 12-14-2005
Deleting the file in a folder

hi everyone

I am having some n number of files in folder I want delete a file which name has todays date example my file name is 14(todaysdate) when i want transfer files i want to delete that file which name has 14.i want delete only 14 file.need help

thanks
srivsn
# 2  
Old 12-14-2005
trythis

use date +%d to form the filename pattern and remove ths files.
# 3  
Old 12-14-2005
Deleting a file

hi my specification is
1)i am reading file in folder and i am renaming that file by reading last line of the file
2)whire renaming the file i am concating new file name with todays date
3)after renaming the file i am transfer that file to another remotel ocation
4)after transfer the files i have to delete the old files from the paraent folder

i am able to do all the requirements but i am getting a single file which name has today date i have to delete that one also

all the files transfering and deleting from the parent folder exept the 14(today named file)

and my code is


day=$(date +%d)
for i in `ls -1 BBW*`
do
last=`tail -1 $i`
pat=`expr "$last" : '.*(\(.*\)).*'`
pat=`echo $pat | sed 's/ /_/'`
pat=$pat$day
mv $i $pat
done
#!/usr/bin/sh
ftp -v -n "10.236.2233" << cmd
user "$1" "$2"
cd $3
mput *_*
bye
cmd
pwd
rm -f *_*
exit


please i am very new to sh.script can you modify the code to delete the only one file which name has 14

thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deleting a pattern in UNIX without deleting the entire line

Hi I have a file: r58778.3|SOURCES={KEY=f665931a...,fw,221-705}|ERRORS={16_1:T,30_1:T,56_1:C,57_1:T,59_1:A,101_1:A,115:-,158_1:C,186_1:A,204:-,271_1:T,305:-,350_1:C,368_1:G,442_1:C,472_1:G,477_1:A}|SOURCE_1="Contig_1092402550638"(f665931a359e36cea0976db191ff60ff09cc816e) I want to retain... (15 Replies)
Discussion started by: Alyaa
15 Replies

2. Shell Programming and Scripting

awk - writing matching pattern to a new file and deleting it from the current file

Hello , I have comma delimited file with over 20 fileds that i need to do some validations on. I have to check if certain fields are null and then write the line containing the null field into a new file and then delete the line from the current file. Can someone tell me how i could go... (2 Replies)
Discussion started by: goddevil
2 Replies

3. UNIX for Dummies Questions & Answers

Deleting folder with Date format

Hi, I have number of directories being created under a main directory on daily basis with the sysdate as below $ pwd /hello/TEST $ ls 20111103 20111102 20111101 20111031 20111030 20111029 20111028 20111027 20111026 20111025 20111024 20111023 20111022 20111021 (3 Replies)
Discussion started by: spari2
3 Replies

4. Shell Programming and Scripting

want to move set of file from one folder to another folder

Hi all, let me explain my requirments i am having 5 folder with different name for eg) abc , cdf , efd, rtg, ead each 5 folders contain 15 files i want to move 10 files to some other folder, remain 5 files should be there in the same folder. give me some suggestion on this. (6 Replies)
Discussion started by: natraj005
6 Replies

5. Shell Programming and Scripting

Can I use a shell script for deleting chunks from a watch folder?

Hello I have a unique problem of needing to delete large files slowly off of an XSan. I was wondering if there is a script I could use to delete 100gb chunks of files and folders that get placed in to a watch folder, slowly so as not to disrupt the other users. I would like to use Automator in... (0 Replies)
Discussion started by: ajsoto
0 Replies

6. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies

7. Shell Programming and Scripting

Deleting the contents of a folder older than X hours

Every day a new .zip file is uploaded to a folder and at mid-night the zip file is to be extracted into a /data/ folder, inside a date-named folder. # This should extract the contents of a zip file into the /data/ folder into a date based folder /usr/bin/unzip -a -o... (15 Replies)
Discussion started by: worchyld
15 Replies

8. Shell Programming and Scripting

Move the file from one folder to another folder

Hi, I have a requirement to move a file from one folder(a) to another folder(b) only when folder (b) have a write permission. Folder permission is 755 If the permission is otherthan 755 we need to come out of the loop I will appreciate your help Thanks Soll (1 Reply)
Discussion started by: sollins
1 Replies

9. Shell Programming and Scripting

Parse the .txt file for folder name and FTP to the corrsponding folder.

Oracle procedure create files on UNIX folder on a regular basis. I need to FTP files onto windows server and place the files, based on their name, in the corresponding folders. File name is as follows: ccyymmddfoldernamefile.txt; Folder Name length could be of any size; however, the prefix and... (3 Replies)
Discussion started by: MeganP
3 Replies

10. Shell Programming and Scripting

deleting files in folder

helloo people... I was trying to do one script that would delete all files in one folder there are 2-3 usefull files in folder all other is junk.. how to say delete all except those 3 files... thanks in advance best regards, (10 Replies)
Discussion started by: amon
10 Replies
Login or Register to Ask a Question