With a recent version of the Korn shell, the built-in printf utility can process date reformatting requests such as:
which, when run in December 2013, produces the output:
I don't know whether the ksh on your AIX system is recent enough to support this, but it is worth a try.
All that to "find" all filenames in a directory containing this date.
Example:
I have a file "56311_0161_012014_M1_25112013.csv" and the bold text is what i'm searching for.
That's why i'm incrementing my current month by 1, coz i launch in december the script for files of the next month.
The find command i use is:
But it's not working as well, 'cause is giving all files in the directory to me, and not ONLY thoose corresponding to my find!
I'll appreciate all help.
Look further for yours.
Last edited by Don Cragun; 12-20-2013 at 09:34 PM..
Reason: Change QUOTE tags to CODE tags.
All that to "find" all filenames in a directory containing this date.
Example:
I have a file "56311_0161_012014_M1_25112013.csv" and the bold text is what i'm searching for.
That's why i'm incrementing my current month by 1, coz i launch in december the script for files of the next month.
The find command i use is:
But it's not working as well, 'cause is giving all files in the directory to me, and not ONLY thoose corresponding to my find!
I'll appreciate all help.
Look further for yours.
$nextMonthFlow_ is being expanded to an empty string. To keep from including the trailing underscore in the variable name, try the following command instead:
About tar all file extracted, in my script, i have 2 alternatives:
1)
Quote:
tar -cvf test_ok.tar `find $(pwd)/03_ok/ -name "*.[Cc][Ss][Vv]" -type f -print -prune`
it works but returns the "test_ok.tar" including the entire path before, instead i want only files included in "/03_ok/", not the subdirectories
2)
Quote:
find $(pwd)/03_ok/ -name "*.[Cc][Ss][Vv]" -type f -print -prune -exec tar -cvf $(pwd)/05_backup/backup_ok.tar
returning an error
Quote:
$ find $(pwd)/03_ok/ -name "*.[Cc][Ss][Vv]" -type f -print -prune -exec tar -cvf $(pwd)/05_backup/backup_ok.tar
find: 0652-018 An expression term lacks a required parameter.
$
I also testet this code:
but with no luck, because the complete path is still there!
About tar all file extracted, in my script, i have 2 alternatives:
1)
it works but returns the "test_ok.tar" including the entire path before, instead i want only files included in "/03_ok/", not the subdirectories
2)
returning an error
I also testet this code:
but with no luck, because the complete path is still there!
Your requirements aren't clear. You have made some ambiguous statements about what isn't working with the code you've shown us, but you never really stated what set of files you are trying to archive. You haven't said much about your directory structure and you haven't told us what $dir_03_ok expands to. I'm guessing that you just want to archive the *.csv (case insensitive) files in the directory named by $dir_03_ok but want the pathnames in the archive to just be the filenames of the files rather than the absolute pathnames of those files. So, this is a wild guess, but try:
or, preferably (if you're using a POSIX compatible shell (like a 1993 or later version of ksh) rather than an old Bourne shell):
Hi, I need the first & last day of a month from any given date. For better understanding, if i need to back-fill data for date 07/20/2019 i.e July 20 2019, i need the first & last day has 07/01/2019 - 07/31/2019. FYI: I'm using GIT BASH terminal.
sample code:
export DT=$(date --date='6 days... (2 Replies)
I am running a script in ksh to get the 2 months back date from system date.The below code is giving correct date output from putty command prompt.But while running the script is .ksh file it is giving the error below.Please suggest.
; d=a; y=a
m-=num
while(m < 1) {m+=12; y--}... (1 Reply)
I have a homework assignment:
----------------------------------------
"Display" the number of days in the current month. For example:
September 1996 has 30 days
----------------------------------------
I am trying to just display the head of cal to start the sentence.
eg. cal | head
... (1 Reply)
I have requirment to get last date of previous month and the first date of previous 4th month:
Example:
Current date: 20130320 (yyyymmdd)
Last date of previous month: 20130228 (yyyymmdd)
First date of previous 4th month: 20121101 (yyyymmdd)
In my shell --date, -d, -v switches are not... (3 Replies)
How could we derive teh Next month in MON-RR format from current date ie sysdate in UNI AIX sheel script.I coould get a command but i supports only inLinux susse andnotin AIX.
I need for Unix AIX.Pls Help.
Regards
Shiv (2 Replies)
Hi,
i unable to get the last month date in AIX.
current date - one month
Based on the forums tried but did not find the relevent information.
Any help grealy appriciated.
Thanks
Suri. (3 Replies)
Hi Gurus,
I'm using HP-UX B.11.23 operating system.
I've been trying to extract this log info based on the current date and month, but was having some issues as the date column which on the 4th column has a comma and the 5th column has a dot tied to it.
Here is the output from my shut... (5 Replies)
Hi All,
I want to find the time diffrence between currnt time and "abc.txt" file create time.
I have solve that but if the abc.txt file created last month then is there any process to find the difftent?
Exp:
Create time of abc.txt is "Apr 14 06:48"
and currect date is "May 17 23:47".... (1 Reply)
i want to delete files that are one day old
condition is files should be of current month only ie if iam running script on 1 march it should not delete files of 28 feb(29 if leap year :-)}
any modifications to
find $DIR -type f -atime +1 -exec rm -f{}\; (4 Replies)