Sponsored Content
Full Discussion: Optimize my mv script
Top Forums Shell Programming and Scripting Optimize my mv script Post 302923789 by Aia on Tuesday 4th of November 2014 12:55:35 PM
Old 11-04-2014
Quote:
Originally Posted by whegra
[...]
Looked to do something odd, it only moved files when the folder did not already exist, so it only moved about 120 files then completed running.
It is not odd.
Change [ ! -d "$d/processed/$b/$a" ] && mkdir -p $d/processed/$b/$a && mv $d/$line $d/processed/$b/$a/
to
Code:
if [ ! -d "$d/processed/$b/$a" ]; then
     mkdir -p $d/processed/$b/$a || continue
fi
mv $d/$line $d/processed/$b/$a/

---------- Post updated at 10:55 AM ---------- Previous update was at 10:50 AM ----------

Quote:
Originally Posted by junior-helper
Is it guarantee that mv would move the file?
No, on that design, unless, further code is added
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

optimize the script

Hi, I have this following script below. Its searching a log file for 2 string and if found then write the strings to success.txt and If not found write strings to failed.txt . if one found and not other...then write found to success.txt and not found to failed.txt. I want to optimize this... (3 Replies)
Discussion started by: amitrajvarma
3 Replies

2. UNIX for Dummies Questions & Answers

Can we optimize this simple script ?

Hi All , I am just a new bie in Unix/Linux . With help of tips from 'here and there' , I just created a simple script to 1. declare one array and some global variables 2. read the schema names from user (user input) and want2proceed flag 3. if user want to proceed , keep reading user... (8 Replies)
Discussion started by: rajavu
8 Replies

3. UNIX for Dummies Questions & Answers

optimize shell script (snapshots)

I've a script to do some snapshots but the time it does so is very different... once i got a snapshot under 1 sec, on the other hand it took 3 sec, but nothing else changed, i didnt even move the cursor or something. I put the script on a ramdisk and its faster, but still swing from under 1... (1 Reply)
Discussion started by: mcW
1 Replies

4. Shell Programming and Scripting

Optimize and Speedup the script

Hi All, There is a script (test.sh) which is taking more CPU usage. I am attaching the script in this thread. Could anybody please help me out to optimize the script in a better way. Thanks, Gobinath (6 Replies)
Discussion started by: ntgobinath
6 Replies

5. Emergency UNIX and Linux Support

Help to optimize script running time

Dear Forum experts I have the below script which I made to run under bash shell, it runs perfectly for low records number, let us say like 100000. when I put all records (3,000,000), it's takes hours can you please suggest anything to optimize or to run in different way :-| {OFS="|";... (6 Replies)
Discussion started by: yahyaaa
6 Replies

6. Shell Programming and Scripting

Can someone please help me optimize my code (script searches subdirectories)?

Here is my code. What it does is it reads an input file (input.txt which contains roughly 2,000 search phrases) and searches a directory for files that contains the search phrase. The directory contains roughly 1900 files and 84 subdirectories. The output is a file (output.txt) that shows only the... (23 Replies)
Discussion started by: jl487
23 Replies

7. UNIX for Dummies Questions & Answers

optimize if block : shell script

Hi, I need a shell script to determine if a no. is either even, greater than 4, less than 8 SHELL : ksh OS : RHEL 6 this is the if block of the script mod=`expr $num % 2` if || || then echo "No. is either even or greater than 4 or less than 8" fi this code works... (2 Replies)
Discussion started by: sam05121988
2 Replies

8. Shell Programming and Scripting

Delete unique rows - optimize script

Hi all, I have the following input - the unique row key is 1st column cat file.txt A response C request C response D request C request C response E request The desired output should be C request (7 Replies)
Discussion started by: varu0612
7 Replies

9. Shell Programming and Scripting

Optimize shell script to run faster

data.file: contact { contact_name=royce-rolls modified_attributes=0 modified_host_attributes=0 modified_service_attributes=0 host_notification_period=24x7 service_notification_period=24x7 last_host_notification=0 last_service_notification=0 host_notifications_enabled=1... (8 Replies)
Discussion started by: SkySmart
8 Replies

10. Shell Programming and Scripting

Help Optimize the Script Further

Hi All, I have written a new script to check for DB space and size of dump log file before it can be imported into a Oracle DB. I'm relatively new to shell scripting. Please help me optimize this script further. (0 Replies)
Discussion started by: narayanv
0 Replies
MU-SERVER(1)						      General Commands Manual						      MU-SERVER(1)

NAME
mu_server - the mu backend for the mu4e e-mail client DESCRIPTION
mu server starts a simple shell in which can manipulate the mu database. The output of the commands is terms of Lisp symbolic expressions (s-exps). mu server is not meant for use by humans; instead, it is designed specifically for the mu4e e-mail client. In this man-page, we document the commands mu server accepts, as well as their responses. In general, the commands sent to the server are of the form <command> [<parameters>]* where each of the parameters is prefixed by their name and a colon. For example, to view a certain message, the command would be: view docid:12345 Parameters can be sent in any order, and parameters not used by a certain command are simply ignored. OUTPUT FORMAT
mu server accepts a number of commands, and delivers its results in the form: 376<length>377<s-expr> 376 (one byte 0xfe), followed by the length of the s-expression expressed as an hexadecimal number, followed by another 377 (one byte 0xff), followed by the actual s-expression. By prefixing the expression with its length, it can be processed more efficiently. The 376 and 377 were chosen since they never occur in valid UTF-8 (in which the s-expressions are encoded). COMMAND AND RESPONSE
add Using the add command, we can add a message to the database. -> add path:<path> maildir:<maildir> <- (:info add :path <path> :docid <docid>) compose Using the compose command, we get the (original) message, and tell what to do with it. The user-interface is then expected to pre- process the message, e.g. set the subject, sender and recipient for a reply message. Messages of type 'new' don't use the docid: parameter, the other ones do. -> compose <reply|forward|edit|new> [docid:<docid>] <- (:compose <reply|forward|edit|new> :original <s-exp> :include (<list-of-attachments)) The <list-of-attachments> is an s-expression describing the attachments to include in the message; this currently only applies to message we are forwarding. This s-exprssion looks like: (:file-name <filename> :mime-type <mime-type> :disposition <disposition>) extract Using the extract command we can save and open attachments. -> extract action:<save|open|temp> index:<index> [path:<path>] [what:<what> [param:<param>]] If the action is 'save', the path argument is required; the attachment will be saved, and a message <- (:info save :message "... has been saved") is sent. If the action is 'open', the attachment will saved to a temporary file, after which it will be opened with the default handler for this kind of file (see mu-extract(1)), and a message <- (:info open :message "... has been opened") is sent. If the action is 'temp', the arguments 'what' is required. The attachment will saved to a temporary file, and the following message is sent: <- (:temp :what <what> :param <param) The front-end can then take action on the temp file, based on what :what and :param contain. mu4e uses this mechanism e.g. for pip- ing an attachment to a shell command. find Using the find command we can search for messages. -> find query:"<query>" [maxnum:<maxnum>] First, this will return an 'erase'-sexp, to clear the buffer from possible results from a previous query. <- (:erase t) This will return a series of 0 up to <maxnum> s-expression corresponding to each message found (if there's no maxnum, all results will be returned). The information message s-exps this function returns do not contain the message body; the view command is for that. <- (...) and finally, we receive: <- (:found <number-of-matches>) index Using the index command, we can (re)index the database, similar to what mu find does. -> index path:<path> As a response, it will send (for each 500 messages): (:info index :status running :processed <processed> :updated <updated>) and finally: (:info index :status complete :processed <processed :updated <updated> :cleaned-up <cleaned-up>) mkdir Using the mkdir command, we can create a new maildir. -> mkdir path:<path> <- (:info mkdir :message "<maildir> has been created") move Using the move command, we can move messages to another maildir or change its flags (which ultimately means it is being move to a different filename), and update the database correspondingly. The function returns an s-exp describing the updated message, so that it can be updated in the user interface. -> move docid:<docid>|msgid:<msgid> [maildir:<maildir>] [flags:<flags>] <- (:update <s-exp> :move t) One of docid and msgid must be specified to identify the message. At least one of maildir and flags must be specified. ping The ping command provokes a pong response. It is used for the initial handshake between mu4e and mu server. -> ping <- (:pong "mu" :version <version> :doccount <doccount>) remove Using the remove command, we can remove the message from disk, and update the database accordingly. -> remove docid:<docid> <- (:remove <docid>) view Using the view command, we can all information (including the body) of a particular e-mail message. -> view docid:<docid>|msgid:<msgid> <- (:view <s-exp>) AUTHOR
Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> SEE ALSO
mu(1) User Manuals April 2012 MU-SERVER(1)
All times are GMT -4. The time now is 04:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy