removing old files from client directory: awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting removing old files from client directory: awk
# 1  
Old 09-17-2008
removing old files from client directory: awk

I would help with removing old files from client directory and put the new files in there.............

Below code gives me wrong outout, it's supposed to delete old files from client directory ............................

am I missing anything ?

{removing *** Hash
Passive mode: off; fallback to active mode: off.
Hash: No such file or directory.
removing *** mark
Passive mode: off; fallback to active mode: off.
mark: No such file or directory.
removing *** printing
Passive mode: off; fallback to active mode: off.
printing: No such file or directory.
removing *** on
-----
-------}
############## Only leave 10 files on the FTP server######
RFILES=`ftp -ni $DEST << foo
user SAMBA$KAMABA
bin
cd ~client/public/daily
epsv4 off
ls -1
bye
foo`
for f in `echo $RFILES | awk '{ for (i = 1; i < (NF - 10); ++i) print $i}'` ; do
echo "let's removing *** $f"
ftp -ni $DEST << foo
user SAMBA$KAMABA
cd ~client/public/daily
pass off
del $f
bye
foo
done
done
fi
done

#################################################
# 2  
Old 09-17-2008
Work on your script one section at a time and make sure that it works before going on to the next part.

First, check that $RFILES contains what you expect it to. Do you get any errors when you just run that part of the script? If so, correct that part before going on to the rest of the script.
# 3  
Old 09-22-2008
thanks

it's an issue with "ls -1" it shows different result in net BSD than Sunos....

adding epsv4 off did the trick.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compressing & removing files in a directory & subdirectory

Hi, I want a simple line of code that will compress files within a directory specified (parameter) and its subdirectories and also i want to remove files which are exactly 365 days old from the sysdate after this compression. Please help. Thanks, JD (8 Replies)
Discussion started by: Jesshelle David
8 Replies

2. UNIX for Dummies Questions & Answers

Removing directory with leading hyphen from root directory

I know that this basic question has been asked many times and solutions all over the internet, but none of the are working for me. I have a directory in the root directory, named "-p". # ls -l / total 198 <snip> drwxr-xr-x 4 root root 4096 Dec 3 14:18 opt drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: edstevens
2 Replies

3. Shell Programming and Scripting

Bash script to copy apache log files to client directory

Our Apache log files are written to a location on the server that we as clients have no access. Don't ask. Every month, I have to e-mail the administrator to have him manually copy our Apache log files to a directory in our file space. You can probably guess how efficient it is to do things this... (3 Replies)
Discussion started by: gregraven
3 Replies

4. Shell Programming and Scripting

awk command to compare a file with set of files in a directory using 'awk'

Hi, I have a situation to compare one file, say file1.txt with a set of files in directory.The directory contains more than 100 files. To be more precise, the requirement is to compare the first field of file1.txt with the first field in all the files in the directory.The files in the... (10 Replies)
Discussion started by: anandek
10 Replies

5. UNIX for Dummies Questions & Answers

Removing a range of files in a directory..

Hi all, Disclosure: I am very new to Unix, but eager to learn.. I've been tasked with transferring logs to a remote server. After I've verified these logs have transferred correctly I have to remove the source files. The naming scheme is: /directory/2012.05.01 /directory/2012.05.02 ..and... (1 Reply)
Discussion started by: JD3V
1 Replies

6. Shell Programming and Scripting

Apply 'awk' to all files in a directory or individual files from a command line

Hi All, I am using the awk command to replace ',' by '\t' (tabs) in a csv file. I would like to apply this to all .csv files in a directory and create .txt files with the tabs. How would I do this in a script? I have the following script called "csvtabs": awk 'BEGIN { FS... (4 Replies)
Discussion started by: ScKaSx
4 Replies

7. Shell Programming and Scripting

help with removing files from home directory

hey there folks! I cant figure out, for the life of me, how to procede in removing alll the files in my home directory that are not owned by me. would i have to list them, but after that what do i do. or is there some way I am not aware of. my employer heard i could script in unix, but i havent... (3 Replies)
Discussion started by: Ginkosu
3 Replies

8. Shell Programming and Scripting

Removing files older than one week in a directory

Hi, I need a shell script to remove the files older than a week in a directoy and if necessary to zip the files. (2 Replies)
Discussion started by: sudhakaryadav
2 Replies

9. UNIX for Dummies Questions & Answers

removing the files but not the directory

How would i rmeove all the files in the directory but still keep the directory? (5 Replies)
Discussion started by: JamieMurry
5 Replies

10. Shell Programming and Scripting

Removing files automatically from a directory after 30 days.

Hello; I have a directory that is collecting log and act files. I need to write a script that will remove these files once they are 30 days old. I have read through a number of threads on this site that have given me a great deal of information. However I have what seems to be a unique... (7 Replies)
Discussion started by: justinb_155
7 Replies
Login or Register to Ask a Question