LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash issue please help! (https://www.linuxquestions.org/questions/linux-newbie-8/bash-issue-please-help-4175488701/)

zcarlile 12-20-2013 01:27 PM

Bash issue please help!
 
So my boss wants me to design a script (I just started working with bash scripting) to move all files with a set string to another directory, and have it echo out "these files have been moved". The first part of the script is working perfect as designed. The problem is he wants a display set to show which files are moved. I thought simple mv -v, that however is not working, the mv part is but its not displaying verbose.

I am now trying to find a way to do in if statement like
modify date=$1 (1 is current date)

any way to call upon the modification date through bash to complete this?

I apologize for the length of this.

lleb 12-20-2013 01:57 PM

sounds like a homework problem. cant help you with homework, but if this is not, first post what you have created and post the display output along with a sample desired output. please use code flags: [ code ] [ / code ] just remove the spaces and copy/paste.

also look into tee -a and >> also create a log file that you can pair >> with.
Code:

echo "moving ${f} now " >> tee -a ${LOG}

jpollard 12-20-2013 02:30 PM

In some ways, this would be a better target for Perl. It has direct methods of getting file status, displays, and even creating windows (if thats what you need). Or maybe Python.

One command that lists the full information about a file is the "stat" command. You can then use awk to pull out the dates of the appropriate field.

zcarlile 12-20-2013 02:49 PM

This is not homework and my boss told me i can use all the resources I need to accomplish this, I have never taken a class on bash and the class i did go through for unix/linux was for a military system.

in regards to the awk command, I am not wanting a file report. Is it possible to do something such as:

list=$1 (for i in 'awk {print $6 $7 $9};) as a variable and then do.

for i in 'll /some/random/file/';
do echo $1;
done

Please forgive me if this is horribly wrong. Like I said, this is the first bit of scripting I have ever done and im teaching myself as I go.

---------- Post added 12-20-13 at 04:50 PM ----------

And that was not suppose to be a smiley face btw

grail 12-20-2013 09:17 PM

Quote:

And that was not suppose to be a smiley face btw
To prevent this you need to use the [code][/code] tags around your code (as suggested in post 2)

As also requested, show the code that you have working along with the part that is not and we will attempt to help ;)

jamison20000e 12-20-2013 09:37 PM

So:
Code:

[noparse];)[/noparse]
:D


All times are GMT -5. The time now is 10:44 PM.