Unix/Linux Go Back    



Find command + replace the extension (.xxx) by *

UNIX for Beginners Questions & Answers




Kindly Note - This is a Single User Post by Forum Member royinfo.alain Regarding:
Find command + replace the extension (.xxx) by *.
Please Follow The Primary Link Above to View the Full Discussion.

   
Old Unix and Linux 04-20-2017
royinfo.alain royinfo.alain is offline
Registered User
 
Join Date: Aug 2016
Last Activity: 24 April 2017, 3:44 PM EDT
Posts: 16
Thanks: 17
Thanked 0 Times in 0 Posts
Find command + replace the extension (.xxx) by *

Hello,

I'm on HP Unix and in a Job, I tried to extract all files from a folder, and replace the extension (.xxxx) by '*' , remove duplicates and move the result in a file..

Example :
Folder has : ABC, CCC.txt, CCC.sf, CCC.sfd, DDD

I need to generate and output file with :

Code:
    ABC*
    CCC*
    DDD*

the commands that I did (See below) is working, but it increased the size of the logs because in my folder it has more than 600 000 files.. Is I can used another command to doing it or do an echo off somewhere and echo on after the execution.. thanks


Code:
[ -f $MAITUT/temp_file_A ] && rm $MAITUT/temp_file_A
[ -f $MAITUT/BCK_TMP_FILES_TO_DELETE ] && rm $MAITUT/BCK_DATA_FILES_TO_DELETE


find * -type f -mtime -365 | while read FileName
do
echo ${FileName%.*}'*' >> $MAITUT/temp_file_A
done

# Remove duplicates

sort -u $MAITUT/temp_file_A > $MAITUT/BCK_DATA_FILES_TO_DELETE

Example of the Info that i have in the logs :


Code:
...

+ read FileName
+ echo ARCAEDF*
+ 1>> /umaitdevapp/home/maitdev/tmp/temp_file_A
+ read FileName
+ echo ARCAMF*
+ 1>> /umaitdevapp/home/maitdev/tmp/temp_file_A
+ read FileName
+ echo ARCAMF*
+ 1>> /umaitdevapp/home/maitdev/tmp/temp_file_A
+ read FileName
+ echo ARCCC*
+ 1>> /umaitdevapp/home/maitdev/tmp/temp_file_A
+ read FileName
+ echo ARCCC*
+ 1>> /umaitdevapp/home/maitdev/tmp/temp_file_A
+ read FileName
+ echo ARCCD*
+ 1>> /umaitdevapp/home/maitdev/tmp/temp_file_A
+ read FileName
+ echo ARCCD*
+ 1>> /umaitdevapp/home/maitdev/tmp/temp_file_A
+ read FileName

...

Thanks a lot
Alain

Last edited by Corona688; 04-20-2017 at 05:01 PM..