Tar command generation with Find


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Tar command generation with Find
# 8  
Old 04-21-2017
I'm working on an HP unix !!
I don't know which shell is it .. maybe bourne..

Do you have an idea how I can combine the FOR and mtime
or mtime it can only use with the command find ?

thanks
# 9  
Old 04-21-2017
What output do you get from running the following two commands:
Code:
uname -a
ls -ld /bin /usr/bin /bin/bash /bin/ksh /bin/sh /usr/bin/bash /usr/bin/ksh /usr/bin/sh

# 10  
Old 04-24-2017
Thanks to all..

I used the code below and works fine & fast.

Code:
set +x
 FILE_TMP=""
FILES=""
 find *.sf -type f -mtime -$nb_days | sed -e "s/.sf/.sfd/g" | while read FileName
do
       FILE_TMP=""
       [ -f $FileName ] && FILE_TMP="$FileName"
       FILES="$FILES $FILE_TMP"
done
 set -x


Moderator's Comments:
Mod Comment Please use CODE tags correctly as required by forum rules!

Last edited by RudiC; 04-24-2017 at 03:51 PM.. Reason: Changed ICODE to CODE tags.
# 11  
Old 04-24-2017
Little shorter and little safer
Code:
set +x
FILES=""
find *.sf -type f -mtime -$nb_days | sed -e "s/[.]sf/.sfd/" |
while read FileName
do
       [ -f "$FileName" ] && FILES="$FILES $FileName"
done
set -x

This only works with ksh or a ksh-derived sh. Other shells will run the while loop in a sub shell that does not return $FILES to the main shell.
# 12  
Old 04-24-2017
Thanks for the Info,

I will use yours.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Single command - unzip files from a tar command

I have a tar file that contains multiple .Z files. Hence I need to issue a tar command followed by a gzip command to fully extract the files. How do I do it in a single command? What I'm doing now is tar xvf a.tar (this will output 1.Z and 2.Z) gzip -d *.Z (to extract 1.Z and 2.Z) (9 Replies)
Discussion started by: ericlim
9 Replies

2. Shell Programming and Scripting

find + tar + gzip + uunecode/email --> in one command?

How to search for all files with matching strings --> find + tar + gzip + uunecode/email them in one command? I am sure there is a right way to pass list of files to tar, then compress tar file. Then send that as attachment using uuencode in one command.. Can we do that!? (3 Replies)
Discussion started by: kchinnam
3 Replies

3. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

4. Shell Programming and Scripting

Dynamic command line generation with awk

Hi, I'm not an expert in awk but i need a simple script to do this: I'd like to AutoCrop PDF files. I found 2 simple script that combined together could help me to automatize :) The first utiliti is "pdfinfo" that it gives the MediaBox and TrimBox values from the pdf. The pdfinfo output... (8 Replies)
Discussion started by: gbagagli
8 Replies

5. Shell Programming and Scripting

tar command dont tar to original directory

HI, if I have a tarfile called pmapdata.tar that contains tar -tvf pmapdata.tar -rw-r--r-- 0/0 21 Oct 15 11:00 2009 /var/tmp/pmapdata/pmap4628.txt -rw-r--r-- 0/0 21 Oct 14 20:00 2009 /var/tmp/pmapdata/pmap23752.txt -rw-r--r-- 0/0 1625 Oct 13 20:00 2009... (1 Reply)
Discussion started by: borderblaster
1 Replies

6. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

7. AIX

command usage on find with xargs and tar

my task : tar up large bunch of files(about 10,000 files) in the current directories that created more than 30 days ago but it come with following error find ./ -ctime +30 | xargs tar rvf test1.tar tar: test1.tar: A file or directory in the path name does not exist. (3 Replies)
Discussion started by: darkrainbow
3 Replies

8. UNIX for Advanced & Expert Users

How to restrict Core file generation after scp (of SSH) command executed in UNIX

Hi, I am getting core file in local machine after trasfer files to other machine by using scp (secure copy) of SSH in UNIX. Could any one please tell me how to restrict core file generatation by using scp command. (4 Replies)
Discussion started by: nrsekhar
4 Replies

9. UNIX for Advanced & Expert Users

How to use the command Tar to find a file

Hello, I am just using the command Tar to find if a file was backuped on my tape. Can you help me with that command. I am using the command : tar -tvf /dev/rmt/4m /kcc_dms/AC7/c15a* > toto.txt to find all files c15a* in these subdirectories on my tape. But it doesn't work correctly. Can... (2 Replies)
Discussion started by: steiner
2 Replies

10. Solaris

Bar code generation in to the text file and printing the same using lp command.

Hi, I need the information regaring bar code printing. I am looking for the program which runs on solaris that take number string (like mobile number, bill number etc) as input and generate bar code font in to the text file. Remember it is not the bit map. The program just writes the fonts in to... (0 Replies)
Discussion started by: Manjunath Naik
0 Replies
Login or Register to Ask a Question