Sponsored Content
Top Forums Shell Programming and Scripting Optimizing the Shell Script [Expert Advise Needed] Post 303007755 by gold2k8 on Tuesday 21st of November 2017 05:17:40 AM
Old 11-21-2017
Optimizing the Shell Script [Expert Advise Needed]

I have prepared a shell script to find the duplicates based on the part of filename and retain latest.
Code:
    #!/bin/bash
    if [ ! -d dup ]; then
        mkdir -p dup
    fi
    NOW=$(date +"%F-%H:%M:%S")
    LOGFILE="purge_duplicate_log-$NOW.log"
    LOGTIME=`date "+%Y-%m-%d %H:%M:%S"`
    echo "$LOGFILE"
    echo "Started at $LOGTIME " >> $LOGFILE
    echo "Before File Count " >> $LOGFILE
    cd /tmp/sathish/GB/
    ls -l | wc -l >> $LOGFILE
    for i in `find /tmp/sathish/GB/ -type f \( -iname "*.xml" \) -printf '%T@ %p\n' | sort -rg | sed -r 's/[^ ]* //' | awk 'BEGIN{FS="_"}{if (++dup[$1] >= 2) print}'`;
    do
    if [! -z $i]; then
    echo "No Duplicates Identified" >>$LOGFILE
    fi
    echo "$i $dup">>$LOGFILE
    mv -v $i dup;
    done
    echo "Ended at $LOGTIME " >> $LOGFILE
    echo "After File Count " >> $LOGFILE
    cd /tmp/sathish/GB/
    ls -l | wc -l >> $LOGFILE

I recently tested this script in test server.

Code:
    Time Taken	22 Min
    Before File Count	227874
    After File Count	58137
    Duplicates Moved to Dup folder	169737

I am unable to implement this production server as it consumes more cpu, any way to optimize this query.

Truly appreciate your expertise advise to minimize the cpu during this process.

Suggestions most welcome
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script help needed

I am trying to query a table having 3 columns, the third column is a field of varchar(1024) with a SQL string in it. I am using cut command to split out the three fields into three variables. I do a db2 command to extract the data into a file. My problem is with the third field having the SQL... (3 Replies)
Discussion started by: fastgoon
3 Replies

2. Shell Programming and Scripting

mail program on shell script didn't work, please advise.

Hi, everyone: I post a new thread because previous post may sink and I hope the new one can be caught by your eyes. I created a shell script and the script works fine. However, the mail program part on script didn't send email to my email box and it also didn't provide any traceable... (7 Replies)
Discussion started by: duke0001
7 Replies

3. Shell Programming and Scripting

Need help optimizing this piece of code (Shell script Busybox)

I am looking for suggestions on how I could possibly optimized that piece of code where most of the time is spend on this script. In a nutshell this is a script that creates an xml file(s) based on certain criteria that will be used by a movie jukebox. Example of data: $SORTEDTMP= it is a... (16 Replies)
Discussion started by: snappy46
16 Replies

4. Shell Programming and Scripting

Need some expert advise on running scripts.

We have couple of scripts made for our environment (which is Oracle Virtulisation ) . Each script is assigned a different task . Some of the scripts are meant to run on centralized server for monitoring other Servers resource utilization such as CPU,Storage. While some are meant to run on... (6 Replies)
Discussion started by: pinga123
6 Replies

5. UNIX for Advanced & Expert Users

os x hdiutil expert needed

I am writing a script that using the "Total Bytes" field from hdiutil imageinfo -plist <file>. My intention is to get the total mounted size of a compressed dmg. It works for some images, but sometimes it doesn't seem to match up, particularly with larger (over 1 gb) images. Can anybody explain... (10 Replies)
Discussion started by: nextyoyoma
10 Replies

6. Shell Programming and Scripting

fgrep command: Perl programming help needed..Kindly advise

Hi, I am novice in PERL enviornment. I have a text files withso many entries in rows and columns. I have to pick up entries named as "Uniprot ID" in the file and create a new text file with list of particular Uniprot ID entries. Can anybody guide regarding this.. I came to know abut fgrep... (1 Reply)
Discussion started by: manigrover
1 Replies

7. Shell Programming and Scripting

How to expert Shell Programming ?

Guys, I have been reading the bash books, there are so many command & operators etc. The theory part is so much. Overall I have read some book. Still do not feel I know the bash with confidence. Lots of Jobs for System Admin demand Scripting knowledge as requirement .. I think I should... (7 Replies)
Discussion started by: heman96
7 Replies

8. Shell Programming and Scripting

Portable shell script advise

All, I have a need for a portable shell script for LInux and HPUX. The script has a simple need; Check for local files of a specific name (i.e. filename*), scp them to another system, and archive them to a folder. The script runs via cron. I first wrote the script in Linux (bash with gnu... (4 Replies)
Discussion started by: hburnswell
4 Replies
GNUNET-DHT-GET(1)					      General Commands Manual						 GNUNET-DHT-GET(1)

NAME
gnunet-dht-get - issue a GET request to the GNUnet DHT, prints results. SYNOPSIS
gnunet-dht-get [options] DESCRIPTION
gnunet-dht-get issue a GET request to the GNUnet DHT and prints results. OPTIONS
-c FILENAME, --config=FILENAME Use the configuration file FILENAME. -h, --help Print short help on options. -k KEY, --key=KEY The query key. -L LOGLEVEL, --loglevel=LOGLEVEL Use LOGLEVEL for logging. Valid values are DEBUG, INFO, WARNING and ERROR. -l LOGFILE, --logfile=LOGFILE Configure logging to write logs to LOGFILE. -r LEVEL, --replication=LEVEL How many parallel requests (replicas) to create. -T TIMEOUT, --timeout=TIMEOUT How long to execute this query before giving up? -t TYPE, --type=TYPE The type of data to look for. -V, --verbose Be verbose (print progress information). -v, --version Print GNUnet version number. BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet-developers@gnu.org> GNUnet Jan 4, 2012 GNUNET-DHT-GET(1)
All times are GMT -4. The time now is 01:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy