Entering in to recent created folder


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Entering in to recent created folder
# 1  
Old 09-13-2008
Data Entering in to recent created folder

Hi,

I had problem

I have a script after each run, which creates a new folder under "testrun",
I used to find recent createfolder by using ls -ltr in testrun folder.

Is there any script which facilitates, going directly to recent createfolder under "testrun"Smilie

Plz help..
# 2  
Old 09-13-2008
One way to go to the recent created directory, but... only within the environment of the script otherwise you have to run the script (source) in the current environment.

Code:
cd `ls -lrt|awk '/^d/{s=$8}END{print s}'`

Regards
# 3  
Old 09-14-2008
Reply

Hi Franklin,

Thanks for help.

But command
cd `ls -lrt|awk '/^d/{s=$8}END{print s}'

it saying "bash: cd: 08:55: No such file or directory"

After running my work script It will create folders under "testrun" like this:

drwxr-x--- 6 systst tpa 1024 Sep 13 11:06 20080913-110615/
drwxr-x--- 6 systst tpa 1024 Sep 13 11:07 20080913-110713/
drwxr-x--- 6 systst tpa 1024 Sep 13 11:07 20080913-110741/
drwxr-x--- 6 systst tpa 1024 Sep 13 11:08 20080913-110850/
drwxr-x--- 6 systst tpa 1024 Sep 13 11:09 20080913-110954/
drwxr-x--- 6 systst tpa 1024 Sep 13 11:10 20080913-111053/
drwxr-x--- 6 systst tpa 1024 Sep 13 11:12 20080913-111200/
drwxr-x--- 6 systst tpa 1024 Sep 13 11:43 20080913-114312/
drwxr-x--- 6 systst tpa 1024 Sep 13 11:44 20080913-114423/
drwxr-x--- 6 systst tpa 1024 Sep 13 11:57 20080913-115746/
drwxr-x--- 6 systst tpa 1024 Sep 13 12:07 20080913-120658/
drwxr-x--- 6 systst tpa 1024 Sep 13 12:16 20080913-121625/
drwxr-x--- 6 systst tpa 1024 Sep 13 12:17 20080913-121720/


I need to enter recent created folder... in above case its 20080913-121720/

Can you check it again.........

Thanks
Prasad
# 4  
Old 09-14-2008
how about
cd `ls -rtF|grep '/$'|tail -n1`
# 5  
Old 09-14-2008
It should be:

Code:
cd `ls -lrt|awk '/^d/{s=$NF}END{print s}'`

The shorter solution of jimcanoa should work too.

Regards
# 6  
Old 09-14-2008
Its working..


Thanks dude,Smilie
# 7  
Old 09-14-2008
Dude,

One more problem Independently cd `ls -lrt|awk '/^d/{s=$NF}END{print s}'` is working.

When I try to create alias in a file like this..
alias k="cd `ls -lrt|awk '/^d/{s=$NF}END{print s}'`"

its not working. its displaying error "bash: cd: oracle/: No such file or directory"

Whts the problem.......
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get filelist in a folder which is created in last x hours

Hi , I am looking for some help in getting the list of files matching some pattern in a folder and those were created in last X hours. Please help. Thanks in advance. (1 Reply)
Discussion started by: Anupam_Halder
1 Replies

2. UNIX for Advanced & Expert Users

Large crout files created in /tmp folder

Hello All, We are having a archiving script which runs every monday. When ever the script runs it creates crout* files in /tmp folder. This file appends till /tmp become 100% full. We are facing this problem now very frequently. We caanot delete this files,we have to kill the script. when we... (5 Replies)
Discussion started by: Upendra Bhushan
5 Replies

3. Solaris

Login delay after entering id (40 secs) same after entering pw

Hi all, I have just installed Solaris 10 on an old Fujitsu Primepower 650 which has been wiped clean. I haven't installed anything apart from the OS yet, so the machine is 99% idle. I get long delays when logging in, first after entering the id then another long delay after entering a valid... (8 Replies)
Discussion started by: longjon
8 Replies

4. UNIX for Advanced & Expert Users

default size of a newly created folder

Hi all, In linux how to create a directory with specified size, so that it can be used only up to the mentioned size. Actually my question is, whether we can do directory quota in linux. mounting the directory in a partiton will do that, but do we have any other option... (1 Reply)
Discussion started by: anishkumarv
1 Replies

5. Shell Programming and Scripting

Entering into C shell remotely

Hi All, I want to enter into C shell from Ksh remotely. I have written code like, remsh $rHost -l $rUser -n "source $RM_HOME/run_time/.set_env.csh; jar -xvf $package.$extension" But it says; ksh: source : not found ksh: jar : not found Can anyone help me? Thanks. (1 Reply)
Discussion started by: AB10
1 Replies

6. Shell Programming and Scripting

Entering parameter automatically

First of all thank you for your replies to my earlier difficulties. Now I am facing another difficulty. I have written following “for” loop. For var in `find . -name “2008_reports*”` Do Gpg -symmetric ${var} Done When I use this loop it asks to enter pass phrase every time. Is there any... (7 Replies)
Discussion started by: anushree.a
7 Replies

7. UNIX for Dummies Questions & Answers

how to find folder size with created date

hi, please give me adivse .how to find the folder size with created created date . eg: i have directore and in that sub directoties and so on.. /home/mud/abc/dcb/ for this i want output like this path size date -------------------------------------------... (3 Replies)
Discussion started by: muddasani
3 Replies

8. Shell Programming and Scripting

Entering secret password

Hello All, I am trying to write a script when executed, asks you for the password, and confirm password; it should save to a file and also entered password should not be in clear text on the console - should be as **** Can somebody give me direction in writing this in shell? Thanks Chiru (4 Replies)
Discussion started by: chiru_h
4 Replies

9. UNIX for Dummies Questions & Answers

Entering directories structured above user.

I wish to enter directories which are on the HD but not part of the user hierarchy and have access to the contents of an external HD. To an advanced user this is probably a stupid question but I experimented with ~, cd, . and.. to no avail. I did check for a suitable command but couldn't find one.... (9 Replies)
Discussion started by: Frank Hunter
9 Replies

10. UNIX for Dummies Questions & Answers

entering a long command

hello everyone! Very basic question for the guru's in here but anyways, I am trying to type a command that is longer than the line. What character do I use to continue my command on the next line? Thanks in advance.... Todd (1 Reply)
Discussion started by: hedrict
1 Replies
Login or Register to Ask a Question