To copy a a file to last created directory..Urgent pls


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To copy a a file to last created directory..Urgent pls
# 1  
Old 01-07-2010
To copy a a file to last created directory..Urgent pls

I need to copy a file example hhh.txt to the recently created directory by name flexite@latesttimestamp in the path interface/home/ ...

I couldnt get the name of recently created directory ....

first result of ls -lst ...that is ls -lst |head -2 gives the latest directory but i could not the name alone...it just shows the result....


Pls help on this regard....
# 2  
Old 01-07-2010
Try:
Code:
ls -t|head -1

# 3  
Old 01-07-2010
not if it's specifically the last created directory...

The problem is: directories get modified when a file is created therein.
So you never know which one was the last one created per se.

This problem can be remedied by cleverly naming them with a sortable timestamp.

At any rate:

Code:
/bin/ls -ltd dir_names* | grep ^d | head -1 | read latest_dir

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How I can find the last file created and move it to a directory?

I have this situation /u03/app/banjobs> ls -ltr icg* 82 Jun 12 10:37 iicgorldi_2419186.log 56810484 Jun 17 10:35 icgorldi_2421592.xml 2859 Jun 17 10:35 icgorldi_2421592.lis - 125 Jun 17 10:35 icgorldi_2421592.log 82 Jun 12 10:37 iicgorldi_2419187.log ... (8 Replies)
Discussion started by: Bernardo Jarami
8 Replies

2. Shell Programming and Scripting

Copy an array to a newly created directory

hello everyone, I am new to perl script and trying to develop a script as follows. I am trying to Create an array for storing all file names. I am trying to copy $libs into "scratch". however i am unable to do so. Please suggest.. #!/usr/bin/perl use File::Copy; #use... (5 Replies)
Discussion started by: Rashid Khan
5 Replies

3. Shell Programming and Scripting

Help Me Pls Its Urgent!!!!!!!!!!!!!!!!

Hi, These are the text file I have //input1.txt// cd dir1/dir2/pg1.txt cd dir3/dir4/pg2.txt cd dir88/dir5/pg4.txt cd dir7/dir6/pg5.txt cd dir8/dir9/pg7.txt And each text file has some text. Now I have to write a shell script which reads input1.txt and changes the directory as shown... (1 Reply)
Discussion started by: bhavanabahety
1 Replies

4. Shell Programming and Scripting

Urgent ...pls Sorting files based on timestamp and picking the latest file

Hi Friends, Newbie to shell scripting. Currently i have used the below to sort data based on filenames and datestamp $ printf '%s\n' *.dat* | sort -t. -k3,4 filename_1.dat.20120430.Z filename_2.dat.20120430.Z filename_3.dat.20120430.Z filename_1.dat.20120501.Z filename_2.dat.20120501.Z... (1 Reply)
Discussion started by: robertbrown624
1 Replies

5. Shell Programming and Scripting

pls help me very urgent

will post again (1 Reply)
Discussion started by: revertback
1 Replies

6. UNIX for Dummies Questions & Answers

Copy a file based on the size-Urgent

Hi, I need unix code to check the size of a file. for example if the size of the file in A folder is more than 1BM, then i have to move that particular file in to B folder whenever I run that particular script. regards, Srinivas. (7 Replies)
Discussion started by: vysrinivas
7 Replies

7. Shell Programming and Scripting

Pls Help me.. soon. Very urgent

I have downloaded the Putty SSH configuration. I have entered my Host name as illinois.engr.sjsu.edu and i am trying to save that. But i am unable to save. Also i opened the session and entered my log in name But it says using keyboard interactive authentication.I am not able to get into $ ... (2 Replies)
Discussion started by: VamsiVasili
2 Replies

8. UNIX for Dummies Questions & Answers

URGENT :pls help

Following is d code snipet #!/bin/ksh retVal=`sqlplus -s user/passwd\@oracle_sid <<EOF SET SERVEROUTPUT ON SIZE 100000 DECLARE STATUS_VALUE VARCHAR2(1); BEGIN SELECT temp1 INTO STATUS_VALUE FROM sai; DBMS_OUTPUT.PUT_LINE(STATUS_VALUE); END; / exit; EOF` echo "Return Value... (2 Replies)
Discussion started by: sainathdeg
2 Replies

9. Shell Programming and Scripting

Pls Help.. Really Urgent

Hi, I am creating a pipe in a directory $HOME/pipes. The pipename should be L${PROGNAME}. Whenever i embed these lines in shell script, i get an error mkfifo: No such file or directory. I am creating a pipe with the key word mkfifo $HOME/pipes/L${PROGNAME}. Please help me how to get... (5 Replies)
Discussion started by: raghavan.aero
5 Replies

10. UNIX for Dummies Questions & Answers

extract some specific text file urgent pls

i have a big text file . i want to create new file as extract some specific text from the big file i am using hp ux please help (2 Replies)
Discussion started by: reyazan
2 Replies
Login or Register to Ask a Question