03-12-2013
You have to prepend whatever input you produce to the second one, of course, like the ls | used above. I added it to the code.
The first code breaks the input line at _ and . as told by the field separator, set with -F. $NF is the last field ("txt"), $(NF-1) the before last field containing the date string. The use of the substr function is self explanatory, I think.
The second works similarly, but leaves the .txt extension intact.
Last edited by RudiC; 03-12-2013 at 05:50 AM..
Reason: typo corrected
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I would like to know how I could get a yesterday date in yyyymmdd e.g. today is 20011109, and I would like to get 20011108. Thank you!:confused: (2 Replies)
Discussion started by: hk_newbie
2 Replies
2. HP-UX
How can i get the yesterday's date in YYYYMMDD format??? (4 Replies)
Discussion started by: prasadsr
4 Replies
3. Shell Programming and Scripting
Okay, I have posted on here one other time and received very fast help, so I figured I'd post again.
Searched for awhile and couldn't find exactly what I'm looking for.
I am attempting to write a script that will search through a given directory, or search through the current directory, and... (10 Replies)
Discussion started by: cbo0485
10 Replies
4. UNIX for Dummies Questions & Answers
I have a file with some date columns in MM/DD/YYYY format:
SMPBR|DUP-DO NOT USE|NEW YORK||16105|BA5270715|6/6/2007 |MWERNER|109||||JOHN||SMITH|MD|72211118||||||74559|21 WILMINGTON RD||D|11/6/2003|SL# MD CONTACT-LIZ RICHARDS|||0|Y|N||1411458|
And I want to convert the date format to:
... (5 Replies)
Discussion started by: ChicagoBlues
5 Replies
5. Shell Programming and Scripting
In my shell script i have a variable which stores date in the format of YYYYMMDD. Is there any way to format this value to MM/DD/YYYY.
Thanks. (8 Replies)
Discussion started by: nasirgondal
8 Replies
6. Shell Programming and Scripting
How do I change the date format from mmddyyyy to yyyymmdd in PERL.
Can any one help me please. (3 Replies)
Discussion started by: thankful123
3 Replies
7. Solaris
Hi Experts,
How to get date 5 days after current date in YYYYMMDD format?
How do we compare date in YYYYMMDD format?
Thanks (1 Reply)
Discussion started by: needyourhelp10
1 Replies
8. Shell Programming and Scripting
Hello Experts,
How do i get date after 5 days from current date in YYYYMMDD format?
How do you compare date in YYYYMMDD format?
Thanks (8 Replies)
Discussion started by: needyourhelp10
8 Replies
9. Shell Programming and Scripting
Hi all,
i had a code where in user will enter a date in yyyymmdd format.. i didnt use any validation for the date and now the problem is if a user enters date instead of month after year it is proceeding with the code..
like if the date is 20120426 and if the user enters 20122604 it... (4 Replies)
Discussion started by: smarty86
4 Replies
10. Shell Programming and Scripting
Record:
Record1|Record2|Record3|Record4|Record5|DATE1|DATE2
Need to Check DATE1 & DATE2 is in DDMMYYYY format in a file.
records which not meet the date format DDMMYYYY extract to other file. (1 Reply)
Discussion started by: vivekn
1 Replies