what happens if more than 2 files with latest dates and i need dynamic script
Moderator's Comments:
Getting 11 warnings to correctly use CODE tags when displaying sample input, sample output, and code segments and having several other cases where moderators have edited your posts to add CODE tags for you without issuing a warning has resulted in this account being placed in read-only mode for three days.
Please review the rules you agreed to when you joined this forum.
Future posting without proper formatting or breaking other forum rules may result in you being permanently banned from this site.
The command:
is never going to produce the output:
because testlog/kSR* is never going to match testlog/log/KSR.
Are you trying to print all filenames with the latest date in the filename:
???
Are you trying to print the most recently modified filenames with different numbers between KSR and _ (which in this case would be the same files)???
Are all of the files you're interested in in a single directory (as shown in your examples)? Or, are they spread out in various directories under the directory /tmp/testlog/log?
Is the first part of the filenames you want to match kSR or KSR?
What operating system are you using?
What shell are you using?
P.S. Is it OK if the most recent file is printed first instead of last?
If you're trying to get the most recent names with different numbers before the underscore, does the order of the output lines matter as long as the filenames you want are all printed?
Hi All,
I have list of files like below with name abcxyz.timestamp. I need a unix command to pick the latest file from the list of below files. Here in this case the lates file is abcxyz.20190304103200. I have used this unix command "ls abcxyz*|tail -1" but i heard that it is not the appropriate... (2 Replies)
Guys,
Someone please guide me to tell me how do I print and later remove all old files in a folder recursively but keep only latest 15 modified files.
When I do - ls -tp | head -15
I get the list of last 15 modified files whereas I need the list of all OTHER files except these files.
... (3 Replies)
Hai
I wolud like to know how to get the latest files.
ex:
file_ssss_00
file_ssss_01
i need to get file_ssss_01 files only. (in Unix script)
Please give some idea ... (2 Replies)
Hi Gurus,
I need to list only those files which are most recent and the latest log file.
For example if I have the following file list:
JOB001.LOG_00uv02_00006 - Jul 7 12:16
JOB001.LOG_00vi0t_00001 - Aug 4 21:58
JOB001.LOG_00vi0t_00002 - Aug 5 09:15
JOB001.LOG_00vi0t_00003 - Aug 5... (6 Replies)
Hi,
There are huge no of files in the directory. If i say ls -ltr it is taking too much time. i want to see only the files for Feb,2009. Please help.
Thanks (3 Replies)
A painfully rudimentary UNIX question for somebody. I've been puzzling over this for the last hour but can't find the right command.
I'm simply trying to get a list of all files - and their full paths - within a folder & subfolders which have extension .php and .js. That's it! No amount of... (1 Reply)
Hi,
I need to get the latest file from a list of files in a particular directory.
Please could anyone help me out to get the file.
Thank you,
- Jay. (1 Reply)