Sponsored Content
Top Forums Shell Programming and Scripting Remove two types of files from a directory Post 302550087 by ch33ry on Wednesday 24th of August 2011 03:19:05 PM
Old 08-24-2011
My system linux and shell...kron

---------- Post updated at 02:55 PM ---------- Previous update was at 02:53 PM ----------
Code:
set -vx
BASE=${FILE##*/}
SOURCE_DIR=/apps/informatica/node1/scripts/test
TARGET_DIR=/apps/informatica/node1/scripts/test/archive
DATESTAMP=`date +%Y-%m-%d`
find $SOURCE_DIR  \( -name "*.log" -o -name "*.out" \) |
while IFS="." read FILE
do
        echo $IFS
        echo $FILE
        BASE=`basename "$FILE"`
         echo "$BASE" >/tmp/$$
        IFS="." read BASE EXT < /tmp/$$
          mv "$FILE" "$TARGET_DIR/$BASE.$DATESTAMP.$EXT"
         if [ $? != 0 ]
         then
        echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
        echo "!                                            !"
        echo "!  Error - Error archiving log file          !"
        echo "!                                            !"
        echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
        exit 11
  fi
done
rm -f /tmp/$$

This is script i am using and its trying mv the files from the archive folder ie TARGET_DIR

---------- Post updated at 03:03 PM ---------- Previous update was at 02:55 PM ----------

........Added to above.......

The FILE is staring the TARGET_DIR Path rather then the SOURCE_DIR path.

why so..........:-(

---------- Post updated at 03:19 PM ---------- Previous update was at 03:03 PM ----------

Sry...My Shell--ksh

Last edited by Scott; 08-24-2011 at 04:29 PM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

find directory with 2 types of files

Trying to use the find command to find any directory which contains a file ending in .zip AND a file ending in .o I'm having trouble specifying multiple files as criteria and have can't seem to figure it out from Unix in a Nutshell and Google. (2 Replies)
Discussion started by: dangral
2 Replies

2. HP-UX

Want to remove files from unix directory

Dear All I am basic user of Unix. i woul like to delete some files (basically 05 and 0801111105) from unix directories but unable to delete it I tried all option. rm , rm -f etc.. but not succeed. Infact it also not allowing me to use chmod option so that i can grant 777 option to... (1 Reply)
Discussion started by: yogi_chavan
1 Replies

3. Shell Programming and Scripting

remove duplicate files in a directory

Hi ppl. I have to check for duplicate files in a directory . the directory has following files /the/folder /containing/the/file a1.yyyymmddhhmmss a1.yyyyMMddhhmmss b1.yyyymmddhhmmss b2.yyyymmddhhmmss c.yyyymmddhhmmss d.yyyymmddhhmmss d.yyyymmddhhmmss where the date time stamp can be... (1 Reply)
Discussion started by: asinha63
1 Replies

4. UNIX for Dummies Questions & Answers

remove old files from a directory

Hello I'm new to this forum, so I did a quick scan of the FAQs to see if my problem had been addressed already, since I believe it is probably a very common need. I was surprised that I did not see anything obvious. I need to remove all files from a directory that have a last modified date... (2 Replies)
Discussion started by: 2davidc8
2 Replies

5. UNIX for Advanced & Expert Users

Can't list or remove files from a directory

Hi I have a problem. One of the directories in /var, on one of my servers, has filled up with loads of files. I have tried to list the directory to see what is in it, but the 'ls' command just hangs. Same thing happens when I try to use 'rm' to remove files from that directory. I can see what... (2 Replies)
Discussion started by: m_smith
2 Replies

6. Shell Programming and Scripting

Remove files from a directory using perl

Hi all, I have the following question. Considder that in the directory /code the script remove.pl exists. What i want is to run this script and remove some files that exist in the directory /dir/tmp. I use the below code but it does not work. system("cd /dir/code"); system("rm FileName"); ... (6 Replies)
Discussion started by: chriss_58
6 Replies

7. UNIX for Dummies Questions & Answers

How to remove directory with subdirectories and files?

I'm trying to remove several directories which contains sun-dirs and files inside. I used the command rm -r <dirname> But, it always ask "examine file in directory <dirname> yes/no?" line by line. So, i need to write "y" for every line. How can i skip this step and remove all directories with... (9 Replies)
Discussion started by: ppa108
9 Replies

8. UNIX for Dummies Questions & Answers

remove files from a directory

I have some empty files that were created from a script I ran that I cannot delete using the rm command.... any ideas as how I can delete them? -rw-r--r-- 1 schroeks x_exp 0 Jul 21 08:24 rrd15CEC -rw-r--r-- 1 schroeks x_exp 0 Jul 21 11:37 rrd15CEC -rw-r--r-- ... (20 Replies)
Discussion started by: freddie88
20 Replies

9. UNIX for Dummies Questions & Answers

Types of File in a directory

Hello, I have several thousand files with different extensions in a directory. Is there a single command to get what the various extensions are with a single command. Thanks for your help! Best, Guss (2 Replies)
Discussion started by: Gussifinknottle
2 Replies

10. Shell Programming and Scripting

Remove duplicate files in same directory

Hi all. Am doing continuous backup of mailboxes using rsync. So whenever a new mail arrives it is automatically copied on backup server. When a new mail arrives it is named as xyz:2, when it is read by the email client an S is appended xyz:2,S Eventually , 2 copies of the same file exist on... (7 Replies)
Discussion started by: coolatt
7 Replies
m17n-dump(1)							 The m17n Library						      m17n-dump(1)

NAME
m17n-dump - dump text image SYNOPSIS
m17n-dump [ OPTION ... ] [ FILE ] DESCRIPTION
Dump a text as PNG image file. The PNG file is written to a file created in the current directory with the name 'BASE.png' where BASE is the basename of FILE. If FILE is omitted, text is read from standard input, and the image is dumped into the file 'output.png'. The following OPTIONs are available. o -s SIZE SIZE is the font size in point. The default font size is 12 point. o -d DPI DPI is the resolution in dots per inch. The default resolution is 300 dpi. o -p PAPER PAPER is the paper size: a4, a4r, a5, a5r, b5, b5r, letter, WxH, or W. In the case of WxH, W and H are the width and height in millimeter. In the case of W, W is the width in millimeter. If this option is specified, PAPER limits the image size. If FILE is too large for a single page, multiple files with the names 'BASE.01.png', 'BASE.02.png', etc. are created. o -m MARGIN MARGIN is the horizontal and vertical margin in millimeter. The default margin is 20 mm. It is ignored when PAPER is not specified. o -c POS POS is the character position of cursor to draw. By default, cursor is not drawn. o -x FILE is assumed to be an XML file generated by the serialize facility of the m17n library, and FILE is deserialized before an image is created. o -w Each line is broken at word boundary. o -f FILTER FILTER is a string containing a shell command line. If this option is specified, the PNG image is not written info a file but is given to FILTER as standard input. If FILTER contains '%s', that part is replaced by a basename of FILE. So, the default behaviour is the same as specifying 'cat > %s.png' as FILTER. If FILTER is just '-', the PNG image is written to stdout. o -a Enable anti-alias drawing. o --family FAMILY Prefer a font whose family name is FAMILY. o --language LANG Prefer a font specified for the language LANG. LANG must be a 2-letter code of ISO 630 (e.g. 'en' for English). o -fg FOREGROUND Specify the text color. The supported color names are those of HTML 4.0 and '#RRGGBB' notation. o -bg BACKGROUND Specify the background color. The supported color names are the same as FOREGROUND, except that if 'transparent' is specified, make the background transparent. o -r Specify that the orientation of the text is right-to-left. o -q Quiet mode. Don't print any messages. o --version Print the version number. o -h, --help Print this message. COPYRIGHT
Copyright (C) 2001 Information-technology Promotion Agency (IPA) Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST) Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License <http://www.gnu.org/licenses/fdl.html>. Version 1.6.2 12 Jan 2011 m17n-dump(1)
All times are GMT -4. The time now is 11:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy