Regarding the [[-n $line ]] you seem keep to have, what are you trying to achieve?
Are you worried about blank input lines perhaps? If so, maybe this would be better:-
An alternate might be to strip them from your input file as you read it in something like:-
This might depend on your OS and shell versions.
From RudiC's code (and above) you have a new file listing those that failed to move so that is what you would want. Hopefully it will be empty, unless you have duplicate files listed. If this is the case, you should sort the input file with the -u flag.
Editing the input file whilst still being read it is not only IO intensive for a large input file, but could have unpredictable results.
@rbatte1 #post15 for my knowledge could you please expalain (grep -Ev "^$" input-file part of the code.
---------- Post updated at 05:58 AM ---------- Previous update was at 05:56 AM ----------
RudiC, please help me to understand sed 's/\o047\| ->.*$//g; s/^/^/' | grep -vxf- file part of the code.
How do i update my processedfile.list file after successful move command.
So if my list file contains 1000 lines, and if all the lines read and successfully moved. then my list file should be empty. else have only the for the failed lines.
As I tried to point out, and I don't know how to phrase it more explicitly, the output of the script IS THE NEW LISTFILE, containing ALL THE FAILURES (i.e. having deleted the successful moves) and so REPLACING the OLD listfile, GIVEN your other process has not modified the old listfile in the meantime.
See the difference between posts #6 and#11 - from 10 entries in your listfile, 9 worked and have disappeared, one (...003...) failed and its entry is printed. You have to remove the OLD listfile - hopefully unmodified by the other process in the meantime - and put the printout in its place.
The sed mangles the mv -v output for the grep -v to follow which then removes the successful entries. cut does the same, btw.
I have a script, which is checking if file exists and move it to another directory
if
then
mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly
mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly
... (9 Replies)
Hi all,
i have a folder, with tons of files containing as following,
on /my/folder/jobs/
some_name_2016-01-17-22-38-58_some name_0_0.zip.done
some_name_2016-01-17-22-40-30_some name_0_0.zip.done
some_name_2016-01-17-22-48-50_some name_0_0.zip.done
and these can be lots of similar files,... (6 Replies)
Hi
In directory /mnt/upload I have about 100 000 files (*.png) that have been created during the last six months. Now I need to move them to right folders. eg:
file created on 2014-10-10 move to directory /mnt/upload/20141010
file created on 2014-11-11 move to directory /mnt/upload/20141111... (6 Replies)
Hi,
Anybody help me to write a Shell Script
Get the latest file from the file list based on created and then move to the target directory.
Tried with the following script: got error.
A=$(ls -1dt $(find "cveit/local_ftp/reflash-parts" -type f -daystart -mtime -$dateoffset) | head... (2 Replies)
Newbie...Thank you for your help.
I am creating my first script that simply generates subdirectories to organize video, music, and text files within those subdirectories from my current working directory.
PROBLEM: I am trying to write a log file that contains, for each file, the original file... (0 Replies)
Ok in my bash script i have 5 options to create a simple html script. I need to create a temporary file and whatever the user types will be stored in that file using html codes. And then I have another option in which that temporary file will be moved to the public_html directory in which the user... (19 Replies)
I Need help for one requirement,
I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix.
Example:
Source Directory : \a
destination Directory : \a\b
File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt)
File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Hello all.
I am new to this forum (and somewhat new to UNIX / LINUX - I started using ubuntu 1 year ago).:b:
I have the following problem that I have not been able to figure out how to take care of and I was wondering if anyone could help me out.:confused:
I have all of my music stored in... (7 Replies)
Hi.
I am actually doing all of this on OSX, but using unix apps and script.
I have built my own transparent rsync/open directory/mobility/etc set of scripts for the firm I work at, and it is all almost complete except for ONE THING.
I have the classic problem with rsync where if a user... (0 Replies)