Sponsored Content
Top Forums Shell Programming and Scripting Help - To copy and compress files one day ago Post 302966091 by JackyJohn on Monday 8th of February 2016 05:19:25 AM
Old 02-08-2016
Dear Don,

Many thanks for your response and sorry for missing information. I have Solaris 9 running on my machine and using bourn shell.


I have used your code to first display the files of yesterday before zipping them, but got the following error.

Code:
root@> ls -l RtpTrcError* | /usr/xpg4/bin/grep -F "$(printf '%(%b %e)T\n' "1 day ago")" | while read _ _ _ _ _ _ _ _ name
> do ls -ltr $name;done
bash: printf: `(': invalid format character

-rw-r--r--   1 rtp99    dba       237210 Feb  7 09:05 RtpTrcError.0000
-rw-r--r--   1 rtp99    dba       235928 Feb  7 10:05 RtpTrcError.0001
-rw-r--r--   1 rtp99    dba       270332 Feb  7 11:05 RtpTrcError.0002
-rw-r--r--   1 rtp99    dba       243644 Feb  7 12:05 RtpTrcError.0003
-rw-r--r--   1 rtp99    dba       236638 Feb  7 13:05 RtpTrcError.0004
-rw-r--r--   1 rtp99    dba       267266 Feb  7 14:05 RtpTrcError.0005
-rw-r--r--   1 rtp99    dba       251980 Feb  7 15:05 RtpTrcError.0006
-rw-r--r--   1 rtp99    dba       251759 Feb  7 16:05 RtpTrcError.0007
-rw-r--r--   1 rtp99    dba       237410 Feb  7 17:05 RtpTrcError.0008
-rw-r--r--   1 rtp99    dba       244197 Feb  7 18:05 RtpTrcError.0009
-rw-r--r--   1 rtp99    dba       335545 Feb  7 19:05 RtpTrcError.0010
-rw-r--r--   1 rtp99    dba       252114 Feb  7 20:05 RtpTrcError.0011
-rw-r--r--   1 rtp99    dba       237055 Feb  7 21:06 RtpTrcError.0012
-rw-r--r--   1 rtp99    dba       236635 Feb  7 22:06 RtpTrcError.0013
-rw-r--r--   1 rtp99    dba       236082 Feb  7 23:06 RtpTrcError.0014
-rw-r--r--   1 rtp99    dba       237209 Feb  8 00:06 RtpTrcError.0015
-rw-r--r--   1 rtp99    dba       245933 Feb  8 01:06 RtpTrcError.0016
-rw-r--r--   1 rtp99    dba       240790 Feb  8 02:06 RtpTrcError.0017
-rw-r--r--   1 rtp99    dba       236859 Feb  8 03:06 RtpTrcError.0018
-rw-r--r--   1 rtp99    dba       236281 Feb  8 04:06 RtpTrcError.0019
-rw-r--r--   1 rtp99    dba       236282 Feb  8 05:06 RtpTrcError.0020
-rw-r--r--   1 rtp99    dba       236635 Feb  8 06:06 RtpTrcError.0021
-rw-r--r--   1 rtp99    dba       237764 Feb  8 07:06 RtpTrcError.0022
-rw-r--r--   1 rtp99    dba       251206 Feb  8 08:06 RtpTrcError.0023
-rw-r--r--   1 rtp99    dba       236990 Feb  8 09:06 RtpTrcError.0024
-rw-r--r--   1 rtp99    dba       235927 Feb  8 10:07 RtpTrcError.0025
-rw-r--r--   1 rtp99    dba       245804 Feb  8 11:07 RtpTrcError.0026
-rw-r--r--   1 rtp99    dba       257839 Feb  8 12:07 RtpTrcError.0027
-rw-r--r--   1 rtp99    dba       236282 Feb  8 13:07 RtpTrcError.0028
-rw-r--r--   1 rtp99    dba       249082 Feb  8 14:07 RtpTrcError.0029
-rw-r--r--   1 rtp99    dba       235927 Feb  8 15:07 RtpTrcError.0030
-rw-r--r--   1 rtp99    dba       244552 Feb  8 16:07 RtpTrcError.0031
-rw-r--r--   1 rtp99    dba       251207 Feb  8 17:07 RtpTrcError.0032
-rw-r--r--   1 rtp99    dba       243910 Feb  8 18:07 RtpTrcError.0033
-rw-r--r--   1 rtp99    dba       300647 Feb  8 19:07 RtpTrcError.0034
-rw-r--r--   1 rtp99    dba       252114 Feb  8 20:07 RtpTrcError.0035
-rw-r--r--   1 rtp99    dba       236282 Feb  8 21:07 RtpTrcError.0036
-rw-r--r--   1 rtp99    dba       235794 Feb  8 22:07 RtpTrcError.0037
-rw-r--r--   1 rtp99    dba       236635 Feb  8 23:07 RtpTrcError.0038
-rw-r--r--   1 rtp99    dba       237274 Feb  9 00:08 RtpTrcError.0039
-rw-r--r--   1 rtp99    dba       245960 Feb  9 01:08 RtpTrcError.0040
-rw-r--r--   1 rtp99    dba       241577 Feb  9 02:08 RtpTrcError.0041
-rw-r--r--   1 rtp99    dba       235574 Feb  9 03:08 RtpTrcError.0042
-rw-r--r--   1 rtp99    dba       235993 Feb  9 04:08 RtpTrcError.0043
-rw-r--r--   1 rtp99    dba       235573 Feb  9 05:08 RtpTrcError.0044
-rw-r--r--   1 rtp99    dba       243290 Feb  9 06:08 RtpTrcError.0045
-rw-r--r--   1 rtp99    dba       245326 Feb  9 07:08 RtpTrcError.0046
-rw-r--r--   1 rtp99    dba       252533 Feb  9 08:08 RtpTrcError.0047
-rw-r--r--   1 rtp99    dba       235728 Feb  9 09:08 RtpTrcError.0048
-rw-r--r--   1 rtp99    dba       237763 Feb  9 10:08 RtpTrcError.0049
-rw-r--r--   1 rtp99    dba       252113 Feb  9 11:08 RtpTrcError.0050
-rw-r--r--   1 rtp99    dba       244197 Feb  9 12:09 RtpTrcError.0051
-rw-r--r--   1 rtp99    dba       237565 Feb  9 13:08 RtpTrcError.0052
-rw-r--r--   1 rtp99    dba       252468 Feb  9 14:08 RtpTrcError.0053
-rw-r--r--   1 rtp99    dba        81689 Feb  9 14:29 RtpTrcError.0054
-rw-r--r--   1 rtp99    dba       249701 Feb  5 12:01 RtpTrcError.0055
-rw-r--r--   1 rtp99    dba       328739 Feb  5 13:01 RtpTrcError.0056
-rw-r--r--   1 rtp99    dba       333158 Feb  5 14:01 RtpTrcError.0057
-rw-r--r--   1 rtp99    dba       260979 Feb  5 15:01 RtpTrcError.0058
-rw-r--r--   1 rtp99    dba       250307 Feb  5 16:02 RtpTrcError.0059
-rw-r--r--   1 rtp99    dba       235878 Feb  5 17:02 RtpTrcError.0060
-rw-r--r--   1 rtp99    dba       259321 Feb  5 18:02 RtpTrcError.0061
-rw-r--r--   1 rtp99    dba       347970 Feb  5 19:02 RtpTrcError.0062
-rw-r--r--   1 rtp99    dba       281365 Feb  5 20:02 RtpTrcError.0063
-rw-r--r--   1 rtp99    dba       236791 Feb  5 21:02 RtpTrcError.0064
-rw-r--r--   1 rtp99    dba       236991 Feb  5 22:02 RtpTrcError.0065
-rw-r--r--   1 rtp99    dba       237410 Feb  5 23:02 RtpTrcError.0066
-rw-r--r--   1 rtp99    dba       236500 Feb  6 00:02 RtpTrcError.0067
-rw-r--r--   1 rtp99    dba       240982 Feb  6 01:02 RtpTrcError.0068
-rw-r--r--   1 rtp99    dba       242204 Feb  6 02:02 RtpTrcError.0069
-rw-r--r--   1 rtp99    dba       237388 Feb  6 03:03 RtpTrcError.0070
-rw-r--r--   1 rtp99    dba       237181 Feb  6 04:03 RtpTrcError.0071
-rw-r--r--   1 rtp99    dba       237764 Feb  6 05:03 RtpTrcError.0072
-rw-r--r--   1 rtp99    dba       236636 Feb  6 06:03 RtpTrcError.0073
-rw-r--r--   1 rtp99    dba       237763 Feb  6 07:03 RtpTrcError.0074
-rw-r--r--   1 rtp99    dba       250499 Feb  6 08:03 RtpTrcError.0075
-rw-r--r--   1 rtp99    dba       235928 Feb  6 09:03 RtpTrcError.0076
-rw-r--r--   1 rtp99    dba       235927 Feb  6 10:03 RtpTrcError.0077
-rw-r--r--   1 rtp99    dba       259542 Feb  6 11:03 RtpTrcError.0078
-rw-r--r--   1 rtp99    dba       251762 Feb  6 12:03 RtpTrcError.0079
-rw-r--r--   1 rtp99    dba       236281 Feb  6 13:03 RtpTrcError.0080
-rw-r--r--   1 rtp99    dba       273124 Feb  6 14:03 RtpTrcError.0081
-rw-r--r--   1 rtp99    dba       234666 Feb  6 15:03 RtpTrcError.0082
-rw-r--r--   1 rtp99    dba       236281 Feb  6 16:03 RtpTrcError.0083
-rw-r--r--   1 rtp99    dba       243490 Feb  6 17:03 RtpTrcError.0084
-rw-r--r--   1 rtp99    dba       252114 Feb  6 18:04 RtpTrcError.0085
-rw-r--r--   1 rtp99    dba       342689 Feb  6 19:04 RtpTrcError.0086
-rw-r--r--   1 rtp99    dba       274091 Feb  6 20:04 RtpTrcError.0087
-rw-r--r--   1 rtp99    dba       237410 Feb  6 21:04 RtpTrcError.0088
-rw-r--r--   1 rtp99    dba       236637 Feb  6 22:04 RtpTrcError.0089
-rw-r--r--   1 rtp99    dba       236082 Feb  6 23:04 RtpTrcError.0090
-rw-r--r--   1 rtp99    dba       237628 Feb  7 00:04 RtpTrcError.0091
-rw-r--r--   1 rtp99    dba       243102 Feb  7 01:04 RtpTrcError.0092
-rw-r--r--   1 rtp99    dba       240807 Feb  7 02:04 RtpTrcError.0093
-rw-r--r--   1 rtp99    dba       236990 Feb  7 03:04 RtpTrcError.0094
-rw-r--r--   1 rtp99    dba       236281 Feb  7 04:04 RtpTrcError.0095
-rw-r--r--   1 rtp99    dba       237919 Feb  7 05:04 RtpTrcError.0096
-rw-r--r--   1 rtp99    dba       235927 Feb  7 06:04 RtpTrcError.0097
-rw-r--r--   1 rtp99    dba       236990 Feb  7 07:04 RtpTrcError.0098
-rw-r--r--   1 rtp99    dba       236635 Feb  7 08:05 RtpTrcError.0099
root@>

Can you please suggest whats wrong with it?

Thanks,

Jacky.

Last edited by JackyJohn; 02-09-2016 at 07:37 AM.. Reason: Add CODE tags for output.
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Compress and copy a Folder

hi Buddies , How can i Compress and move a folder through UNIX completely to windows 2000 through FTP. (1 Reply)
Discussion started by: scorpiyanz
1 Replies

2. Shell Programming and Scripting

Cron to run first day of month to calculate date 3 months ago

Hi, I would like to find out how can i calculate a date which is 3 months ago. I intend to run a cron job on the 1st of every month, and calculate the month 4 months earlier from the date. For example, if today's date is 1st May 2007, i would like to return 012007( January 2007). i can get... (1 Reply)
Discussion started by: new2ss
1 Replies

3. UNIX for Dummies Questions & Answers

Copy and compress

Is there a way to copy a file and compress it at the same time? I realize the file can be copied and then compressed, but I was wondering if it's possible to do it in a one-line command and for that matter, if it would be more efficient to perform the operation with a one-line command? Thanks. (5 Replies)
Discussion started by: here2learn
5 Replies

4. UNIX for Dummies Questions & Answers

Copy Compress as one command

Hi, I need to copy and compress files in a directory in single line of command. I am able to copy and gzip files in one command but not directory. Command that I am using for copying directory is below : cp -rp /u01/app/<directory> /u01/app/backup |gzip -r /u01/app/backup/<directory> ... (10 Replies)
Discussion started by: findprakash
10 Replies

5. Shell Programming and Scripting

How to extract the day of the year and use that info to copy a file remotely

Hello, Thank you in advance for helping a newbie who is having great trouble with this simple task. I'm allowed to copy one file remotely each night due to bandwidth restrictions. A new file gets generated once a day, and I need to copy the previous day's file. Here is what I'd like to do:... (1 Reply)
Discussion started by: tmozdzen
1 Replies

6. Shell Programming and Scripting

Help - compress file one day ago

Hi All, I'm a new member of this Forum. I have need your help to handle this request. "Compress a file name not of today but of yesterday only". For example 0 mar 08:00 TEST_RPT_STATUS_M1I_CMI20120320.xls 20 mar 08:00 TEST_RPT_STATUS_M1I_CMI20120320.rep 21 mar 08:00... (6 Replies)
Discussion started by: gio123bgg
6 Replies

7. Shell Programming and Scripting

script to compress files in directory that changes its name every day

Hi all I have the following script that should compress a file in a directory: # compress log files older than 2 days find /u01/easydone/DBDUMPS/*.dmp -mtime +2 -exec gzip {} \; BUT the problem is that these files that I want to compress are inside a directory with following format: ... (5 Replies)
Discussion started by: fretagi
5 Replies

8. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

9. Shell Programming and Scripting

How to copy all structure folder create last day?

HI All, please help , i got same case . i want copy folder and directory create yesterday. for sample below : drwxr-xr-x 4 apps apps 33 Nov 23 04:00 xxxxxx@gmai.com drwxr-xr-x 4 apps apps 33 Nov 23 04:00 yyyyyyy@gmail.com drwxr-xr-x 4 apps apps 33 Nov 24 04:00... (2 Replies)
Discussion started by: fajar_3t3
2 Replies
All times are GMT -4. The time now is 12:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy