Bash find latest files




















Hi, We've a list of files that gets created on a weekly basis and it has got a date and time embedded to it. Below are the examples. I want to find out how to get the latest files get the date and time stamp out of it. Files are PQR Find the latest file on remote sftp. Hi All, I need your help in finding the latest files in remote sftp and get those files to local server and process them.

Please let me know I appreciate your valuable inputs. Thanks raj 7 Replies. Get the latest file from UNIX. Can you pls help me with the below problem: i want to get the latest file from unix to mainframes. How to find the latest file on Unix or Linux recursive.

Hi all, I need to get the latest file. I have found this command "ls -lrt" that is great but not recursive. Can anyone help? Thanx by advance. How to find the latest modified file from the unix server. I need to find out latest modified file. Please help me. Is there a way to use find command to get the latest file and cp it into a certain dir at the same try. Are you saying you want to take the list of files from find and sort them by date? Oh, I see. I think. Add a comment. Active Oldest Votes.

To print the last 3 accessed files sorted from the last accessed file to the third last accessed file : find. Improve this answer. Command is not honouring the year — SHW. SHW Not sure what you mean. The files are sorted based on the number of seconds passed from January 1st To help other users: if you want to scan another directory than the current directory, replace the. It took me a couple of minutes to understand it. These commands break for filenames that contains whitespaces.

Show 2 more comments. If you want the files in a given directory sorted by modification age most recent first : ls -t To sort by access time, add the -u option. Gilles 'SO- stop being evil' Gilles 'SO- stop being evil' k gold badges silver badges bronze badges. RichardO RichardO 61 1 1 silver badge 2 2 bronze badges. Append cut -d ' ' -f2 to get filename only — qwr.

You can also cull the output of head to include a certain number of lines. I only needed the first line, so I used head -n 1 — Timmah. Although better append cut -d ' ' -f2 - to avoid problems with filenames that contain spaces.

Show 1 more comment. Pat Regan Pat Regan 1 1 silver badge 2 2 bronze badges. This doesn't handle subdirectories. I confirm, is faster. One more point, I just found sort -r will wrong if filename across multiple lines exist.

This is a really fast solution that just keeps track of the most recently modified file instead of sorting the entire list of files : find. In the end I resorted to putting! Just to be sure I wasn't dealing with any infinite loops I modified the file to!

Prasanth S Prasanth S 1, 10 10 silver badges 12 12 bronze badges. This is the only answer that actually works correctly for me. The other answers produced some files that weren't actually the most recent.

Thank you, almost 8 years later. Obviously, it's a bit slower than find - my home directory, containing files, was sorted by mc in almost 14 minutes while find spent less than 5 - but there are some benefits: I'd probably spend longer then the 9 minutes difference inventing a proper find invocation : less chance of an error forgot to specify -r for sort etc.

Sergey Sergey 42k 11 11 gold badges silver badges bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Important : Use the correct date format as reference in the find command above, once you use a wrong format, you will get an error as the one below:. You can get more usage information for ls and find commands in our following series of articles on same.

Make use of the feedback form below to send us any question s or comments about the topic. You can as well inform us of any commands used for the same goal. TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web.

Millions of people visit TecMint! If you like what you are reading, please consider buying us a coffee or 2 as a token of appreciation. We are thankful for your never ending support.



jodigena1983's Ownd

0コメント

  • 1000 / 1000