Hello,
I am working through a test Linux script from a website, and am running into some issues. The point of the script is to find image files throughout the system, copy them to one centralized directory,ignore duplicate images with the same name, and output a text file of all the images copied.
The script is below.
Some comments:
- Unless you have good reasons (which?), why do you limit the execution to the sh shell?
- Your usage/error msg comes if $2 exists - is that expected behaviour?
- What are you using the results of the first find for?
- Do you want to copy or move the files?
- Do you know about the -v option to both cp and mv?
Last edited by RudiC; 11-25-2015 at 04:23 AM..
Reason: typo
-The example I was following was limiting the function to a bash shell only
- I want it to output an error message if both directories exist to tell the user how to run the program
- I am using the first find to find all the images that match this format IMG_0000.JPG
- I want to copy the files into an archive folder without any sub folders.
- No
What already has been said:
1. The usage message comes if "$2" is passed (See 3.)
Anyway, the user passes a target dir, sees the usage message, and a list of files found in $1 - that list is not -- cannot be -- used -- later on again, --> unrequired/obsolete.
In addition:
2. Use more (often) quotes around variables (imagine file names with spaces, though not wanted, but might happen anyway.
3. [ -d "$1" ] Checks if $1 is a directory [ -z "$1" ] Checks if an argument has been passed at all
If no argument has been passed, say so, dont use the (unescaped) variable-name, as that part will be empty if no argument has been passed.
Likewise for the destination.
Example:
4. Place the results of find into variables (lists), as that could help to remove duplicates.
Some of the find commands, look (to my eyes) unused...
Last but not least, since not really relevant, try to stick to one coding style, i see like 3 or even 4 different styles.
Makes the reading easier (specialy without syntax highlighting).
But maybe you just need to figure your coding style first, so no worries.
And to repeat RudiC, since i dont feel that has been provided yet...
Quote:
The issues are WHAT?
Elaborate, dont just say what you want, but what is, what you have tried to fix, where you stuck?
Requirement:
Under fuse application we have placeholders called containers;
Every container has their logs under:
<container1>/data/log/fuse.log
<container1>/data/log/fuse.log.1
<container1>/data/log/fuse.log.XX
<container2>/data/log/fuse.log... (6 Replies)
Hey everyone, just now joined because I didn't want to go onto Ubuntu forums and start asking about how to write shell scripts. Seems like this is a pretty active forum for exactly what I need.
I'm trying to modify a shell script I found online, the end goal is to have it find all files in the... (9 Replies)
Hello All,
I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60%
Need to identify the unique file system that reaches threshold value.
ex:
capacity
... (4 Replies)
Hi All,
I have a requirement to archive processed file and retain the archive based on the quantity.. but this is in windows.
I have written a drafted shell script, and would like to have it translated into Batch script.. Please...
Below is the drafted shell script
... (2 Replies)
Hi all,
I am new to linux and scripting so please forgive me. I need to create a script that will archive files but the max size of the archive need to be 500mb or under. I know about the archiving with parts but i want all the archives as individual archives. Can anyone point me in the correct... (7 Replies)
I'm not sure how to solve the $month-1 thingy or the foreach sentence, so I need some help./*
folders =
folder1
folder2
folder3
folder4
folder5
*/
month=`date +%m`
if($month == 01)
{
prev_month = 12
} else
{
prev_month =... (7 Replies)
Hi All
We have a landing directory where source system puts files.There are variable number of files and the file names are also varying.Each files successful transmission is identified by a .done file.If file name is xyz.dat then the confirmation file will be xyz.dat.done.
I want to... (1 Reply)
hi guru,
can advise how to construct a housekeeping script using perl for the following ?
find /var/tmp/logs -name "si*" -type f -exec gzip -f {} \;
find /var/tmp/logs -name "*.gz" -type f -exec mv -f {} /var/tmp/log \;
I found out those are not working in shell at when put them on... (1 Reply)
Hi, (HP-UX 11.11)
I need to create a tape image of an igniteUX image created on our igniteUX server.
That is to say. I have a "Online" image of the igniteUX of the targeted system but I now need to copy it to a useable TAPE (igniteUX) image so i can build an other server from it that is not... (3 Replies)