moving files after ls -lt command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting moving files after ls -lt command
# 1  
Old 12-08-2008
moving files after ls -lt command

Can you please tell me how to find a file in a directory and then if it exists i need to place it in a different folder?
I have to use "ls -lt" command


I mean this command is something existing one . can you please tell me how i set the directory path. Like

dir1/dir2/filename.csv to dir3/dir4/filename.csv

Regards,
# 2  
Old 12-08-2008
are you looking for this??
this will copy filename from corrent dir to required dir3/dir4/
Code:
if [ -f filename ]
then
mv filename dir3/dir4/.
fi

# 3  
Old 12-08-2008
pochaman,

Why did you delete all the questions of your previous threads?

Is this homework?
# 4  
Old 12-08-2008
being that they say they MUST to us "ls -lt" I would guess so.
# 5  
Old 12-08-2008
Quote:
Originally Posted by Franklin52
pochaman,

Why did you delete all the questions of your previous threads?

Is this homework?
Franklin,

Not a homework. I had one thread before this regarding special code. Smilie
# 6  
Old 12-08-2008
Quote:
Originally Posted by Ikon
being that they say they MUST to us "ls -lt" I would guess so.
Ikon,
ls -lt is already used in the prior existing codes
and so since i am not good at unix i tried to understand how to do it.
# 7  
Old 12-08-2008
And what where the reasons to remove (hide?) the questions of these threads?

https://www.unix.com/unix-advanced-ex...flat-file.html

https://www.unix.com/unix-advanced-ex...p-plz-sed.html

Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Moving Hidden files to normal files

I have a bunch of hidden files in a directory in AIX. I would like to move these hidden files as regular files to another directory. Say i have the following files in directory /x .test~1234~567 .report~5678~123 .find~9876~576 i would like to move them to directory /y as test~1234~567... (10 Replies)
Discussion started by: umesh.narain
10 Replies

2. Shell Programming and Scripting

Finding files with wc -l results = 1 then moving the files to another folder

Hi guys can you please help me with a script to find files with one row/1 line of content then move the file to another directory my script below runs but nothing happens to the files....Alternatively Ca I get a script to find the *.csv files with "wc -1" results = 1 then create a list of those... (5 Replies)
Discussion started by: Dj Moi
5 Replies

3. Shell Programming and Scripting

issue while moving files using find command

Hi Friends, I'm facinf issue while moving large files using find command.I've a scenario like i've to move one day older files from one directory to anothe directory.I'm using the below command. find $src_dir -name error -prune -o -type f -mtime +1 -exec mv {} $dest_dir \; some times... (1 Reply)
Discussion started by: mail2mura
1 Replies

4. UNIX for Dummies Questions & Answers

Moving Multiple files to destination files

I am running a code like this foreach list ($tmp) mv *_${list}.txt ${chart}_${list}.txt #mv: when moving multiple files, last argument must be a directory mv *_${list}.doc ${chart}_${list}.doc #mv: when moving multiple files, last argument must be a... (3 Replies)
Discussion started by: animesharma
3 Replies

5. Shell Programming and Scripting

Issue while moving files using find command

Hi All, I'm facing this below error when I move files using find command....Please help out...... $ find /home/aa/ab -mtime +90 -type f -exec mv -f {} /home/aa/ab/ac \; mv: 0653-405 /home/aa/ab/ac/MP_060520111245.csv and /home/aa/ab/ac/MP_060520111245.csv are identical. mv: 0653-405... (2 Replies)
Discussion started by: HemaV
2 Replies

6. Shell Programming and Scripting

moving the files in a.txt files to a different directory

HI All, I am coding a shell script which will pick all the .csv files in a particular directoryand write it in to a .txt file, this .txt file i will use as a source in datastage for processing. now after the processing is done I have to move and archive all the files in the .txt file to a... (5 Replies)
Discussion started by: subhasri_2020
5 Replies

7. Shell Programming and Scripting

using mv command for moving multiple files in a folder

Hi, I have a requirement where I need to move Bunch of folders containing multiple files to another archive location. i want to use mv command .I am thinking when we use mv command to move directory does it create directory 1st and then move all the files ? e.g source... (4 Replies)
Discussion started by: rkmbcbs
4 Replies

8. Shell Programming and Scripting

moving files alone using mv command??

Is there a way to move the files ALONE from one dir to another dir? In my source dir,I have files as well as directories.I want to move the files alone to another dir and the directories should remain undisturbed. If I use mv * < target dir> ,then the directories also moved. Any... (4 Replies)
Discussion started by: prasperl
4 Replies

9. Shell Programming and Scripting

Moving files

I wrote a script which moves files on first in first out basis. for i in `ls -ltr | grep ^- | head -10 | awk '{print $9}'` do mv $i Test/ done But donno some reason, this is not working on my Linux box. May i know the reason? Can the above script be done by using positional... (2 Replies)
Discussion started by: venkatesht
2 Replies

10. Shell Programming and Scripting

moving between vi files

would any one please tell me which keys we used between opened vi files backward and forward Thanks Ayah (2 Replies)
Discussion started by: aya_r
2 Replies
Login or Register to Ask a Question