Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This 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!


  Search this Thread
Old 12-20-2013, 01:27 PM   #1
LQ Newbie
Registered: Dec 2013
Location: Longview tx
Posts: 5

Rep: Reputation: Disabled
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.
Old 12-20-2013, 01:57 PM   #2
Senior Member
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
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.
echo "moving ${f} now " >> tee -a ${LOG}
Old 12-20-2013, 02:30 PM   #3
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,696

Rep: Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261
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.
Old 12-20-2013, 02:49 PM   #4
LQ Newbie
Registered: Dec 2013
Location: Longview tx
Posts: 5

Original Poster
Rep: Reputation: Disabled
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;

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
Old 12-20-2013, 09:17 PM   #5
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,505

Rep: Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890
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
Old 12-20-2013, 09:37 PM   #6
Senior Member
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US, Earth, end border$! ◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that works well on my cheapest; has been KDE or CLI but open... &c ;-)
Posts: 3,553
Blog Entries: 2

Rep: Reputation: 1054Reputation: 1054Reputation: 1054Reputation: 1054Reputation: 1054Reputation: 1054Reputation: 1054Reputation: 1054


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash: Variable issue? fatalerror0x00 Programming 2 11-15-2012 10:09 AM
[SOLVED] Bash and path issue chiendarret Linux - Software 3 01-25-2012 01:13 AM
Bash and mysql issue papa2ae Linux - Newbie 6 06-14-2011 04:39 PM
PHP and Bash Issue tamer1009 Linux - Newbie 8 06-14-2011 06:28 AM
Installation issue with 5.2 and bash sullivjp AIX 2 07-18-2006 09:44 AM

All times are GMT -5. The time now is 08:17 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration