Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
# Append current date to all files
for file1 in $(ls *[a-z].xlsx)
do
basefile1=$(echo $file1 |awk -F. '{print $1}')
current_time=$(date "+_%m%d%Y.xlsx")
mv $file1 ${basefile1}${current_time}
done
# Create variable
current_folder=$(date "+%m%d%Y")
# Make folder
mkdir "$current_folder"
# Change permissions of folder
chmod 777 /dir1/dir2/dir3/reports/${current_folder}
# Move files into folder labelled with the current date
mv *.xlsx "${current_folder}"
# Move whole folder to local shared Windows folder
mv "${current_folder}" //dir1/dir2/dir3/reports/dir4/dest_folder
Everything was working fine but now all of the sudden after the sysadmins did 'maintenance' the whole script works , but now it only moves the biggest file in the folder and nothing else. I personally think the disk is running out of space.Is something wrong with my script? Like I stated earlier it was running perfectly fine and moving ALL files in the folder just fine.
It all started with the so called maintenance done, then I was not able to 'rm' an archive file. Now everything works BUT it only moves the biggest file
I feel what might be useful here is to see more data, on the data. Debug mode for the script as it finds files because perhaps there's a new issue which is causing only certain files to be found. Then additional information on the input and expected output. Which is to say, "new files are xxxx, yyyy, zzzz, and their sizes are .... (for instance show an ls -l output of it all), and then cite what is supposed to happen, and finally describe what did happen.
I realize you did say this, however you said it in general versus using the specific data, or some edited representation of the data so as to not reveal information you have to protect.
Well it's only .xlsx files in a current dated folder. I'm using Oracle EDQ to create these reports and send them to a shared Windows folder. For a week everything was working ok until the sysadmins did some patching. I am very reluctant to change ANY of my code since it was working ok until THEY did some patching. Yes because of my job I can't really give all the info, but I did my best to provide you with a clear picture of what is happening. I feel things just dont happen for a week then all of the sudden mess up.I think it's clear that whatever 'patching' they did messed things up. If you look at my comments in my code, if someone would like to provide more efficient code Im open to that too
My point is that the commands likely are not affected too much by their upgrades. In fact, their upgrades were to Windows, correct?
Your script, correct me on this point, is run by Linux or cygwin running attached to this drive or machine?
Either case, the script fundamentals are very simple: for loop, ls command, mv command, chmod command.
Therefore the directory structure is a possible item in question.
As I cited, it is sometimes difficult to give true examples, however there are a few ways I'd approach this, and they go back to the same recommendations for when you developed your script:
set -xv within the script to debug it and other methods
Manual entry of the commands which do not appear to be working to debug what is happening
Getting "representative" information for the data, such as an ls -l where you remove all the attributes for owner, group, filename, and only show that it is "a" xlsx file of a certain size.
My point is that the commands likely are not affected too much by their upgrades. In fact, their upgrades were to Windows, correct?.....This is correct
Your script, correct me on this point, is run by Linux or cygwin running attached to this drive or machine?.....It is ran by Linux
Out of curiosity, why would the directory structure cause an issue?
I have no idea what "//dir1/dir2/dir3/reports/dir4/dest_folder" represents, except that you physically have the directory structure named: //dir1/dir2/dir3/reports/dir4/dest_folder
Why is there a double // before all that? I do not feel it is required, unless this is something you've already tested and discovered that it was required?
I have plenty of issues with the script as it stands, but as that is a second issue, please follow the suggestion of using set-xv to get output which can be diagnosed.
---
Not saying such is better or something is wrong. Only saying what comes to my mind.
I fiddled a bit with it, but can't test it well. I am beginner. Anyway here would be my approach, but on a pastebin site (so it doesn't look like a proposed solution). Don't get me wrong, don't be angry at me. :-) Only ideas. Look at it, perhaps it contains useful for you. Else ignore http://paste.debian.net/909737/
@nodir...You are no beginner posting suggestions like that. I am the beginner.
Can someone please post code that would do the same as my code above, but better. I am a beginner and the only way I got to the code I provided was by help from someone else on this site which was working just fine. I've ran out of ideas. Meanwhile Ill do the 'set -xv' suggestion.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.