LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-29-2012, 07:20 AM   #1
prravin1
Member
 
Registered: Feb 2012
Location: India
Posts: 43

Rep: Reputation: Disabled
Unhappy Script to enter generated output folders depending on time


I have a script which after executing generates a parent folder containing some sub-folders and scripts within it. This script can generate multiple such folders.

Ex- Script_parent.sh test1 test2

The test1 , test2 are folders contains some date and are passed as arguments too the scripts.

Now the Script_parent.sh will create two folders with time stamps.

ie 12-jan-2012.0 and 12-jan-2012.1

The last digit represent the version of the folder.

The folders will be created in the same directory.

Now i need a script which should run the script and after execution should enter the respective folder that is generated by it.

How can i know which folder is generated when and enter in accordingly?

Last edited by prravin1; 02-29-2012 at 07:34 AM.
 
Old 02-29-2012, 07:45 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 20,101

Rep: Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812
Quote:
Originally Posted by prravin1 View Post
I have a script which after executing generates a parent folder containing some sub-folders and scripts within it. This script can generate multiple such folders.

Ex- Script_parent.sh test1 test2

The test1 , test2 are folders contains some date and are passed as arguments too the scripts. Now the Script_parent.sh will create two folders with time stamps. ie 12-jan-2012.0 and 12-jan-2012.1 The last digit represent the version of the folder. The folders will be created in the same directory.

Now i need a script which should run the script and after execution should enter the respective folder that is generated by it. How can i know which folder is generated when and enter in accordingly?
Another homework question?? Can you show us what you've written so far? Also, if you just put in "linux bash script find dates on files", the VERY FIRST HIT is on this site, where this has been asked (and answered) before:
http://www.linuxquestions.org/questi...script-163731/

Also, since this is homework, have you checked your textbooks, or any of the bash scripting tutorials?
 
1 members found this post helpful.
Old 02-29-2012, 07:46 AM   #3
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 427Reputation: 427Reputation: 427Reputation: 427Reputation: 427
Hi.

Simplest thing that comes to mind is to compare directory listings before and after running your script:
Code:
$ find  -maxdepth 1 -type d > list1
$ mkdir test-dir
$ find  -maxdepth 1 -type d > list2
# Get a list of new directories:
$ diff  list[12]  | sed -n 's/> *//p'
./test-dir
 
1 members found this post helpful.
Old 02-29-2012, 08:28 AM   #4
prravin1
Member
 
Registered: Feb 2012
Location: India
Posts: 43

Original Poster
Rep: Reputation: Disabled
Unhappy

Quote:
Originally Posted by firstfire View Post
Hi.

Simplest thing that comes to mind is to compare directory listings before and after running your script:
Code:
$ find  -maxdepth 1 -type d > list1
$ mkdir test-dir
$ find  -maxdepth 1 -type d > list2
# Get a list of new directories:
$ diff  list[12]  | sed -n 's/> *//p'
./test-dir
That's a useful solution. But how can i enter to the latest directory.

Like > cd test-dir

I need some automation like after the new folders are created, the directory should be changed to respective folders.
 
Old 02-29-2012, 08:31 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 20,101

Rep: Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812Reputation: 4812
Quote:
Originally Posted by prravin1 View Post
That's a useful solution. But how can i enter to the latest directory.
Like > cd test-dir
I need some automation like after the new folders are created, the directory should be changed to respective folders.
Again, since this is your homework, have you checked your textbooks, or any of the bash scripting tutorials???? You've got to show some effort on your own.
http://tldp.org/LDP/abs/html/

If you want to change directories, you've got the "cd" command, and you've been given the commands (several times), on how to find the latest one. What's stopping you from putting them together?
 
1 members found this post helpful.
Old 02-29-2012, 08:37 AM   #6
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 243Reputation: 243Reputation: 243
Quote:
Originally Posted by prravin1 View Post

How can i know which folder is generated when and enter in accordingly?
The folder is generated by the script line that generates the folder
After this line you can enter in this folder ?

It seems too easy so I am surelly missing something though
 
1 members found this post helpful.
Old 02-29-2012, 08:43 AM   #7
prravin1
Member
 
Registered: Feb 2012
Location: India
Posts: 43

Original Poster
Rep: Reputation: Disabled
Wink

Quote:
Originally Posted by TB0ne View Post
Again, since this is your homework, have you checked your textbooks, or any of the bash scripting tutorials???? You've got to show some effort on your own.
http://tldp.org/LDP/abs/html/

If you want to change directories, you've got the "cd" command, and you've been given the commands (several times), on how to find the latest one. What's stopping you from putting them together?
I am a newbie to shell scripting and so get stuck in basic concepts. I am thankful to you for pointing my inefficiencies and also suggesting me future path.

i will definitely try to improve my knowledge so that i can contribute in a positive way.
 
Old 02-29-2012, 10:37 AM   #8
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 427Reputation: 427Reputation: 427Reputation: 427Reputation: 427
Hi.

Quote:
Originally Posted by Cedrik View Post
The folder is generated by the script line that generates the folder
After this line you can enter in this folder ?

It seems too easy so I am surelly missing something though
I agree, it is the best way, if the script is editable.
 
  


Reply


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
scripting logic sushil.cool Linux - Newbie 3 03-04-2010 11:41 AM
LSI Logic / Symbios Logic 53c875 (rev 14) -> HP Storageworks 1/8 G2 gileravxr Linux - Hardware 0 07-21-2009 04:45 AM
Logic Problem lucky6969b Programming 9 12-18-2005 10:44 PM
logic h/w Programming 8 01-02-2004 04:44 PM
logic design athenerx Programming 2 02-02-2002 06:24 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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